summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-30 09:43:07 +0000
committerrubidium <rubidium@openttd.org>2008-08-30 09:43:07 +0000
commite06c21426eaec662e64b02e3c0097dfaaa658d97 (patch)
tree61153cf8dfa71ad1a88c4cccd0d039930750995a /src
parentbfcd6e977233d0acf6da81461f132feb7c5aacf5 (diff)
downloadopenttd-e06c21426eaec662e64b02e3c0097dfaaa658d97.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.cpp4
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;
}