From 943031bdaf52a66d7b9b59fce694654ce1450ffd Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 30 Aug 2008 09:43:07 +0000 Subject: (svn r14190) -Codechange: use alloc instead of malloc+free when the allocated memory shouldn't be used after the function ended. --- src/spriteloader/grf.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index 6f01ee713..0bd73f927 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -30,8 +30,7 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, * In case it is uncompressed, the size is 'num' - 8 (header-size). */ num = (type & 0x02) ? sprite->width * sprite->height : num - 8; - /* XXX -- We should use a pre-located memory segment for this, malloc/free is pretty expensive */ - byte *dest_orig = MallocT(num); + byte *dest_orig = AllocaM(byte, num); byte *dest = dest_orig; /* Read the file, which has some kind of compression */ @@ -100,6 +99,5 @@ bool SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, for (int i = 0; i < sprite->width * sprite->height; i++) if (sprite->data[i].m != 0) sprite->data[i].a = 0xFF; - free(dest_orig); return true; } -- cgit v1.2.3-70-g09d2