diff --git a/src/ai.c b/src/ai.c index 5d2581b..00aba6f 100644 --- a/src/ai.c +++ b/src/ai.c @@ -662,7 +662,7 @@ static int ai_pushtask(lua_State* L) { if(lua_isstring(L, 2)) func = (char*)lua_tostring(L, 2); else LLUA_INVALID_PARAMETER(); - t = MALLOC_L(Task); + t = malloc(sizeof(Task)); t->next = NULL; t->name = strdup(func); t->dtype = TYPE_NULL; diff --git a/src/input.c b/src/input.c index b9ba214..0ac929b 100644 --- a/src/input.c +++ b/src/input.c @@ -179,7 +179,7 @@ void input_init(void) { /* Create a null keybinding for each. */ for(i = 0; strcmp(keybindNames[i], "end"); i++) { - tmp = MALLOC_L(Keybind); + tmp = malloc(sizeof(Keybind)); tmp->name = (char*)keybindNames[i]; tmp->type = KEYBIND_NULL; tmp->key = SDLK_UNKNOWN; diff --git a/src/lephisto.h b/src/lephisto.h index 4c074b2..92c778d 100644 --- a/src/lephisto.h +++ b/src/lephisto.h @@ -8,9 +8,6 @@ #define APPNAME "Lephisto" /**< Application name. */ -#define MALLOC_L(type)(malloc(sizeof(type))) /**< Deprecated. */ -#define CALLOC_L(type)(calloc(1, sizeof(type))) /**< Deprecated. */ - #define ABS(x) (((x)<0)?-(x):(x)) /**< Return absulute value. */ #define FABS(x) (((x)<0.)?-(x):(x)) /**< Return float absolute value. */ diff --git a/src/opengl.c b/src/opengl.c index d37cc21..c8ecb66 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -405,7 +405,7 @@ glTexture* gl_loadImage(SDL_Surface* surface) { int rw, rh; /* Set up the texture defaults. */ - glTexture* texture = MALLOC_L(glTexture); + glTexture* texture = malloc(sizeof(glTexture)); texture->w = (double)surface->w; texture->h = (double)surface->h; texture->sx = 1.; diff --git a/src/physics.c b/src/physics.c index 55b8657..e0598f5 100644 --- a/src/physics.c +++ b/src/physics.c @@ -270,7 +270,7 @@ void solid_init(Solid* dest, const double mass, const double dir, /* Create a new solid. */ Solid* solid_create(const double mass, const double dir, const Vec2* pos, const Vec2* vel) { - Solid* dyn = MALLOC_L(Solid); + Solid* dyn = malloc(sizeof(Solid)); if(dyn == NULL) ERR("Out of memory"); solid_init(dyn, mass, dir, pos, vel); return dyn; diff --git a/src/pilot.c b/src/pilot.c index 735f424..9edac1f 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -1602,7 +1602,7 @@ unsigned int pilot_create(Ship* ship, char* name, int faction, Pilot* dyn; - dyn = MALLOC_L(Pilot); + dyn = malloc(sizeof(Pilot)); if(dyn == NULL) { WARN("Unable to allocate memory."); return 0; @@ -1635,7 +1635,7 @@ Pilot* pilot_createEmpty(Ship* ship, char* name, int faction, char* ai, const unsigned int flags) { Pilot* dyn; - dyn = MALLOC_L(Pilot); + dyn = malloc(sizeof(Pilot)); pilot_init(dyn, ship, name, faction, ai, 0., NULL, NULL, flags | PILOT_EMPTY); return dyn; } @@ -1714,6 +1714,10 @@ void pilot_free(Pilot* p) { solid_free(p->solid); if(p->mounted != NULL) free(p->mounted); if(p->escorts) free(p->escorts); + +#ifdef DEBUGGING + memset(p, 0, sizeof(Pilot)); +#endif free(p); } diff --git a/src/player.c b/src/player.c index 98dfc74..ea7da70 100644 --- a/src/player.c +++ b/src/player.c @@ -2549,11 +2549,10 @@ int player_save(xmlTextWriterPtr writer) { /* Mission the player has done. */ xmlw_startElem(writer, "missions_done"); - for(i = 0; i < missions_ndone; i++) { m = mission_get(missions_done[i]); if(m != NULL) /* In case mission name changes between versions. */ - xmlw_elem(writer, "done", mission_get(missions_done[i])->name); + xmlw_elem(writer, "done", m->name); } xmlw_endElem(writer); /* missions_done. */ diff --git a/src/ship.c b/src/ship.c index 04812e7..ad00090 100644 --- a/src/ship.c +++ b/src/ship.c @@ -375,7 +375,7 @@ static int ship_parse(Ship* tmp, xmlNodePtr parent) { cur = node->children; do { if(xml_isNode(cur, "outfit")) { - otmp = MALLOC_L(ShipOutfit); + otmp = malloc(sizeof(ShipOutfit)); otmp->data = outfit_get(xml_get(cur)); stmp = xml_nodeProp(cur, "quantity"); if(!stmp) diff --git a/src/weapon.c b/src/weapon.c index cc846ce..a9bcb6b 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -729,7 +729,8 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* Weapon* w; /* Create basic features. */ - w = CALLOC_L(Weapon); + w = malloc(sizeof(Weapon)); + memset(w, 0, sizeof(Weapon)); w->faction = pilot_get(parent)->faction; /*Non-Changeable. */ w->parent = parent; /* Non-Changeable. */ w->target = target; /* Non-Changeable. */ @@ -1119,6 +1120,11 @@ static void weapon_destroy(Weapon* w, WeaponLayer layer) { */ static void weapon_free(Weapon* w) { solid_free(w->solid); + +#ifdef DEBUGGING + memset(w, 0, sizeof(Weapon)); +#endif + free(w); }