Removed the now unnecessary casting for malloc calls.

This commit is contained in:
Julie Marchant 2019-05-23 11:07:03 -04:00
parent 908a6059ac
commit b251acb4fe
10 changed files with 12 additions and 14 deletions

View File

@ -1187,7 +1187,7 @@ int alien_add()
int *alienArray;
int numberOfAliens = 1;
alienArray = (int*)malloc(8 * sizeof(int));
alienArray = malloc(8 * sizeof(int));
if (alienArray == NULL)
{
engine_warn("WARNING: Failed to allocate memory for aliens");

View File

@ -34,7 +34,7 @@ void bullet_add(Object *theWeapon, Object *attacker, int y, int dy)
int imageIndex;
int tempX, tempY, steps;
bullet = (Object*)malloc(sizeof(Object));
bullet = malloc(sizeof(Object));
if (bullet == NULL)
return;

View File

@ -143,7 +143,7 @@ void collectable_add(float x, float y, int type, int value, int life)
}
}
Collectable *collectable = (Collectable*)malloc(sizeof(Collectable));
Collectable *collectable = malloc(sizeof(Collectable));
if (collectable == NULL)
{
engine_warn("Failed to allocate memory for collectable");

View File

@ -759,9 +759,7 @@ enum {
};
extern const char * const systemNames[];
extern const char * const systemBackground[];
extern const int rate2reload[6];
#endif

View File

@ -60,7 +60,7 @@ void engine_init()
engine.smx = 0;
engine.smy = 0;
engine.bulletHead = (Object*)malloc(sizeof(Object));
engine.bulletHead = malloc(sizeof(Object));
if (engine.bulletHead == NULL)
{
engine_error("Failed to allocate memory for bullet head.");
@ -68,7 +68,7 @@ void engine_init()
engine.bulletHead->next = NULL;
engine.bulletTail = engine.bulletHead;
engine.explosionHead = (Object*)malloc(sizeof(Object));
engine.explosionHead = malloc(sizeof(Object));
if (engine.explosionHead == NULL)
{
engine_error("Failed to allocate memory for explosion head.");
@ -76,7 +76,7 @@ void engine_init()
engine.explosionHead->next = NULL;
engine.explosionTail = engine.explosionHead;
engine.collectableHead = (Collectable*)malloc(sizeof(Collectable));
engine.collectableHead = malloc(sizeof(Collectable));
if (engine.collectableHead == NULL)
{
engine_error("Failed to allocate memory for collectable head.");
@ -84,7 +84,7 @@ void engine_init()
engine.collectableHead->next = NULL;
engine.collectableTail = engine.collectableHead;
engine.debrisHead = (Object*)malloc(sizeof(Object));
engine.debrisHead = malloc(sizeof(Object));
if (engine.debrisHead == NULL)
{
engine_error("Failed to allocate memory for debris head.");

View File

@ -33,7 +33,7 @@ to change frames on a 21, 14, 7 basis.
*/
void explosion_add(float x, float y, int type)
{
Object *explosion = (Object*)malloc(sizeof(Object));
Object *explosion = malloc(sizeof(Object));
if (explosion == NULL)
{
engine_warn("Failed to allocate memory for explosion.");

View File

@ -233,7 +233,7 @@ static void game_addDebris(int x, int y, int amount)
for (int i = 0 ; i < amount ; i++)
{
debris = (Object*)malloc(sizeof(Object));
debris = malloc(sizeof(Object));
debris->next = NULL;
debris->x = x;

View File

@ -44,7 +44,7 @@ SDL_Surface *gfx_messageBox;
void gfx_init()
{
screen_bufferHead = (LinkedRect*)malloc(sizeof(LinkedRect));
screen_bufferHead = malloc(sizeof(LinkedRect));
if (screen_bufferHead == NULL)
{
engine_error("Failed to allocate memory for buffer head.");

View File

@ -56,7 +56,7 @@ void screen_drawBackground()
void screen_addBuffer(int x, int y, int w, int h)
{
LinkedRect *rect = (LinkedRect*)malloc(sizeof(LinkedRect));
LinkedRect *rect = malloc(sizeof(LinkedRect));
rect->next = NULL;
rect->x = x;

View File

@ -663,7 +663,7 @@ void title_showCredits()
// FIXME: It would be nice for the size of this array to be determined
// by the number of lines in the text file. I'm not sure how to do
// that at the moment, so just giving it a very large number for now.
credit = (TextObject*) malloc(sizeof(TextObject) * 300);
credit = malloc(sizeof(TextObject) * 300);
while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2)
{