Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/stbi reduce stack usage of stbi_gif_load_from_memory...
details: https://anonhg.NetBSD.org/src/rev/cf6672d804f4
branches: trunk
changeset: 772902:cf6672d804f4
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Jan 20 23:13:47 2012 +0000
description:
reduce stack usage of stbi_gif_load_from_memory when STBI_SMALL_STACK is
defined
diffstat:
sys/dev/stbi/stb_image.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diffs (48 lines):
diff -r dc6e8c5dacf2 -r cf6672d804f4 sys/dev/stbi/stb_image.c
--- a/sys/dev/stbi/stb_image.c Fri Jan 20 23:01:05 2012 +0000
+++ b/sys/dev/stbi/stb_image.c Fri Jan 20 23:13:47 2012 +0000
@@ -430,7 +430,7 @@
#endif
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.1 2011/02/06 23:13:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.2 2012/01/20 23:13:47 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -4601,16 +4601,30 @@
{
uint8 *u = 0;
stbi s;
+ stbi_gif *pg;
+
+ #ifdef STBI_SMALL_STACK
+ pg = (stbi_gif *) MALLOC(sizeof(*pg));
+ if (pg == NULL)
+ return NULL;
+ #else
stbi_gif g;
-
- memset(&g, 0, sizeof(g));
+ pg = &g;
+ #endif
+
+ memset(pg, 0, sizeof(*pg));
start_mem(&s, buffer, len);
- u = stbi_gif_load_next(&s, &g, comp, req_comp);
+ u = stbi_gif_load_next(&s, pg, comp, req_comp);
if (u == (void *) 1) u = 0; // end of animated gif marker
if (u) {
- *x = g.w;
- *y = g.h;
+ *x = pg->w;
+ *y = pg->h;
}
+
+ #ifdef STBI_SMALL_STACK
+ FREE(pg);
+ #endif
+
return u;
}
Home |
Main Index |
Thread Index |
Old Index