1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-16 20:49:43 +02:00

ubb-la/gui.c (textf): vasprintf ain't alloca, so we need to free()

This commit is contained in:
Werner Almesberger 2013-01-31 01:45:42 -03:00
parent cdcfb6c181
commit 52c3dcc16a

View File

@ -122,17 +122,18 @@ static void update(void)
static void textf(int x, int y, uint32_t color, const char *fmt, ...)
{
va_list ap;
char *s;
char *tmp, *s;
uint8_t *p;
int ix, iy;
int res;
va_start(ap, fmt);
res = vasprintf(&s, fmt, ap);
if (vasprintf(&tmp, fmt, ap) < 0) {
perror("vasprintf");
exit(1);
}
va_end(ap);
(void) res;
while (*s) {
for (s = tmp; *s; s++) {
p = gfxPrimitivesFontdata+(*s << 3);
for (iy = 0; iy != 8; iy++) {
for (ix = 0; ix != 8; ix++)
@ -141,8 +142,8 @@ static void textf(int x, int y, uint32_t color, const char *fmt, ...)
p++;
}
x += 8;
s++;
}
free(tmp);
}