From ec77a7037586864ece6505c448ab5c15bf8a57d9 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 10 May 2016 17:25:12 -0400 Subject: refactor how submodules are handled let them own their own memory, so that they can free themselves once they exit the loop. also split out the parts of the terminal that we only want to initialize once, even if we open multiple terminal windows --- src/display.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/display.c') diff --git a/src/display.c b/src/display.c index 5558725..20487ff 100644 --- a/src/display.c +++ b/src/display.c @@ -28,9 +28,14 @@ static int runes_display_loc_is_between( struct vt100_loc loc, struct vt100_loc start, struct vt100_loc end); -void runes_display_init(RunesDisplay *display, char *font_name) +RunesDisplay *runes_display_new(char *font_name) { + RunesDisplay *display; + + display = calloc(1, sizeof(RunesDisplay)); runes_display_recalculate_font_metrics(display, font_name); + + return display; } void runes_display_set_context(RunesTerm *t, cairo_t *cr) @@ -157,10 +162,12 @@ void runes_display_draw_cursor(RunesTerm *t) } } -void runes_display_cleanup(RunesDisplay *display) +void runes_display_delete(RunesDisplay *display) { cairo_pattern_destroy(display->buffer); g_object_unref(display->layout); + + free(display); } static void runes_display_recalculate_font_metrics( -- cgit v1.2.3-54-g00ecf