diff options
author | rubidium <rubidium@openttd.org> | 2008-08-30 09:43:07 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-30 09:43:07 +0000 |
commit | 943031bdaf52a66d7b9b59fce694654ce1450ffd (patch) | |
tree | 61153cf8dfa71ad1a88c4cccd0d039930750995a /src | |
parent | 76895a93f46acee0d94400463cf61d84c3c79501 (diff) | |
download | openttd-943031bdaf52a66d7b9b59fce694654ce1450ffd.tar.xz |
(svn r14190) -Codechange: use alloc instead of malloc+free when the allocated memory shouldn't be used after the function ended.
Diffstat (limited to 'src')
-rw-r--r-- | src/spriteloader/grf.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
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<byte>(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; } |