summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-28 05:47:55 +0000
committertron <tron@openttd.org>2006-06-28 05:47:55 +0000
commita370ca97d6efe42c6d8485fccc44969095341eca (patch)
treea0affc827b42b9192c45e99b0b61eaabc1c49f4a
parent2f6c73f0985f7bb4307ce6e0b7fa189d65d11369 (diff)
downloadopenttd-a370ca97d6efe42c6d8485fccc44969095341eca.tar.xz
(svn r5394) Allocate a small, fixed-size array on the stack instead of malloc()ing it
-rw-r--r--screenshot.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/screenshot.c b/screenshot.c
index 34acd1e62..5cbe2012d 100644
--- a/screenshot.c
+++ b/screenshot.c
@@ -393,15 +393,15 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
success = fwrite(palette, 256 * sizeof(*palette), 1, f) == 1;
} else {
/* If the palette is word-aligned, copy it to a temporary byte array */
- byte *tmp = malloc(256 * 3);
+ byte tmp[256 * 3];
uint i;
+
for (i = 0; i < 256; i++) {
tmp[i * 3 + 0] = palette[i].r;
tmp[i * 3 + 1] = palette[i].g;
tmp[i * 3 + 2] = palette[i].b;
}
- success = fwrite(tmp, 256 * 3, 1, f) == 1;
- free(tmp);
+ success = fwrite(tmp, sizeof(tmp), 1, f) == 1;
}
fclose(f);