aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-22 19:44:44 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-22 19:44:44 +0000
commit5907729f75c49763d3950cd13c8ab43836b37279 (patch)
treec26ddffbca489d2ffedd042835d548f8f1f99331
parent57dc9ca6d79aa42f7a49b714bb81f0d73578938b (diff)
drop unneeded alloc/free
-rw-r--r--gui.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gui.c b/gui.c
index 4d5ee10..fe22b9f 100644
--- a/gui.c
+++ b/gui.c
@@ -58,17 +58,12 @@ setpixel(SDL_Surface *s, int x, int y, Uint8 c)
*buf = c;
}
-SDL_Surface *
-mkglyph(unsigned char ch, Uint8 fg, Uint8 bg, unsigned short *m)
+void
+mkglyph(SDL_Surface *g, unsigned char ch, Uint8 fg, Uint8 bg, unsigned short *m)
{
- SDL_Surface *g;
Uint8 c;
int i;
- g = SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWPALETTE, gl.w, gl.h, 8, 0, 0, 0, 0);
- SDL_SetColors(g, color, 0, 16);
-
-
ch &= 0x7f;
ch <<= 1;
@@ -85,8 +80,6 @@ mkglyph(unsigned char ch, Uint8 fg, Uint8 bg, unsigned short *m)
c = m[CHARS + ch + 1] & (0x0001 << i) ? fg : bg;
setpixel(g, 3, i, c);
}
-
- return g;
}
#if 0
@@ -138,6 +131,10 @@ guiemu(unsigned short *m, unsigned short *r)
screen = SDL_SetVideoMode(scr.w, scr.h, 8, SDL_HWSURFACE|SDL_HWPALETTE);
SDL_SetColors(screen, color, 0, 16);
+
+ glyph = SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWPALETTE, gl.w, gl.h, 8, 0, 0, 0, 0);
+ SDL_SetColors(glyph, color, 0, 16);
+
setfont(m);
to.w = gl.w;
@@ -160,10 +157,9 @@ guiemu(unsigned short *m, unsigned short *r)
bg = (ch >> 8) & 0x0f;
fg = (ch >> 12) & 0x0f;
- glyph = mkglyph(ch, fg, bg, m);
+ mkglyph(glyph, ch, fg, bg, m);
SDL_BlitSurface(glyph, &gl, screen, &to);
- SDL_FreeSurface(glyph);
}
}
@@ -201,5 +197,6 @@ guiemu(unsigned short *m, unsigned short *r)
}
leave:
+ SDL_FreeSurface(glyph);
SDL_FreeSurface(screen);
}