Date:2013-01-31 05:45:42 (11 years 1 month ago)
Author:Werner Almesberger
Commit:52c3dcc16a317425fbf29b4221a0e06b70c81f16
Message:ubb-la/gui.c (textf): vasprintf ain't alloca, so we need to free()

Files: ubb-la/gui.c (2 diffs)

Change Details

ubb-la/gui.c
122122static void textf(int x, int y, uint32_t color, const char *fmt, ...)
123123{
124124    va_list ap;
125    char *s;
125    char *tmp, *s;
126126    uint8_t *p;
127127    int ix, iy;
128    int res;
129128
130129    va_start(ap, fmt);
131    res = vasprintf(&s, fmt, ap);
130    if (vasprintf(&tmp, fmt, ap) < 0) {
131        perror("vasprintf");
132        exit(1);
133    }
132134    va_end(ap);
133    (void) res;
134135
135    while (*s) {
136    for (s = tmp; *s; s++) {
136137        p = gfxPrimitivesFontdata+(*s << 3);
137138        for (iy = 0; iy != 8; iy++) {
138139            for (ix = 0; ix != 8; ix++)
...... 
141142            p++;
142143        }
143144        x += 8;
144        s++;
145145    }
146    free(tmp);
146147}
147148
148149

Archive Download the corresponding diff file

Branches:
master



interactive