aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/wm/wm.c5
-rw-r--r--libs/libgui/gfx.c17
-rw-r--r--libs/libgui/gfx.h1
-rw-r--r--libs/libgui/psf.c1
-rw-r--r--libs/libtxt/keymap.c1
5 files changed, 22 insertions, 3 deletions
diff --git a/apps/wm/wm.c b/apps/wm/wm.c
index 8f3b21f..00dedd0 100644
--- a/apps/wm/wm.c
+++ b/apps/wm/wm.c
@@ -462,6 +462,7 @@ static void handle_message(void *msg)
static void handle_exit(void)
{
+ log("Handle\n");
if (keymap)
free(keymap);
@@ -472,10 +473,8 @@ static void handle_exit(void)
struct node *iterator = windows->head;
while (iterator) {
struct window *win = iterator->data;
- if (win->ctx.fb == screen.fb)
+ if (win->ctx.fb)
sys_free(win->ctx.fb);
- else if (win->ctx.fb)
- free(win->ctx.fb);
free(win);
iterator = iterator->next;
}
diff --git a/libs/libgui/gfx.c b/libs/libgui/gfx.c
index db09d21..c26f59a 100644
--- a/libs/libgui/gfx.c
+++ b/libs/libgui/gfx.c
@@ -59,6 +59,16 @@ static void load_font(enum font_type font_type)
assert(fonts[font_type]);
}
+static void free_fonts(void)
+{
+ for (u8 i = 0; i < FONT_COUNT; i++) {
+ if (fonts[i]) {
+ free(fonts[i]->raw);
+ free(fonts[i]);
+ }
+ }
+}
+
static void write_char(struct context *ctx, vec2 pos, struct font *font, u32 c, char ch)
{
int bypp = ctx->bpp >> 3;
@@ -107,8 +117,14 @@ struct context *gfx_new_ctx(struct context *ctx, vec2 size, u8 bpp)
}
// On-demand font loading
+static u8 fonts_loaded = 0;
struct font *gfx_resolve_font(enum font_type font_type)
{
+ if (!fonts_loaded) {
+ fonts_loaded = 1;
+ atexit(free_fonts);
+ }
+
if (!fonts[font_type])
load_font(font_type);
return fonts[font_type];
@@ -187,6 +203,7 @@ void gfx_load_image_filter(struct context *ctx, vec2 pos, enum gfx_filter filter
srcfb += bmp.pitch - diff;
destfb += ctx->pitch - diff;
}
+ free(bmp.data);
}
void gfx_load_image(struct context *ctx, vec2 pos, const char *path)
diff --git a/libs/libgui/gfx.h b/libs/libgui/gfx.h
index f01a6a2..c3fe5d3 100644
--- a/libs/libgui/gfx.h
+++ b/libs/libgui/gfx.h
@@ -53,6 +53,7 @@ enum gfx_filter {
// Generalized font struct
struct font {
+ void *raw;
char *chars;
vec2 size;
int char_size;
diff --git a/libs/libgui/psf.c b/libs/libgui/psf.c
index 751421a..95678ed 100644
--- a/libs/libgui/psf.c
+++ b/libs/libgui/psf.c
@@ -48,6 +48,7 @@ struct font *psf_parse(char *data)
}
struct font *font = malloc(sizeof(*font));
+ font->raw = data;
font->chars = chars;
font->size.x = width;
font->size.y = height;
diff --git a/libs/libtxt/keymap.c b/libs/libtxt/keymap.c
index 67054f6..9e65bf9 100644
--- a/libs/libtxt/keymap.c
+++ b/libs/libtxt/keymap.c
@@ -84,6 +84,7 @@ struct keymap *keymap_parse(const char *path)
map(keymap, line, ch, ch_index);
index++;
}
+ free(keymap_src);
return keymap;
}