From 8e262181e6f85bc89dfed652d971a876c7e6e153 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 23 Oct 2013 22:45:41 +0100 Subject: When destroying framebuffer, ensure any cursor is destroyed. --- include/cursor.h | 3 +++ src/cursor.c | 10 ++++++++++ src/libnsfb.c | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/include/cursor.h b/include/cursor.h index 076e6c9..15751bd 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -38,4 +38,7 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor); /** Clear the cursor restoring the image underneath */ bool nsfb_cursor_clear(nsfb_t *nsfb, struct nsfb_cursor_s *cursor); +/** Destroy the cursor */ +bool nsfb_cursor_destroy(struct nsfb_cursor_s *cursor); + #endif /* CURSOR_H */ diff --git a/src/cursor.c b/src/cursor.c index 5e3f41e..87633dc 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -150,3 +150,13 @@ bool nsfb_cursor_clear(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) return true; } + +bool nsfb_cursor_destroy(struct nsfb_cursor_s *cursor) +{ + /* Note: cursor->pixel isn't owned by us */ + + free(cursor->sav); + free(cursor); + + return true; +} diff --git a/src/libnsfb.c b/src/libnsfb.c index 250df00..4d652c1 100644 --- a/src/libnsfb.c +++ b/src/libnsfb.c @@ -15,6 +15,7 @@ #include "libnsfb_plot.h" #include "libnsfb_event.h" #include "nsfb.h" +#include "cursor.h" #include "palette.h" #include "surface.h" @@ -58,9 +59,14 @@ nsfb_free(nsfb_t *nsfb) if (nsfb->plotter_fns != NULL) free(nsfb->plotter_fns); + if (nsfb->cursor != NULL) + nsfb_cursor_destroy(nsfb->cursor); + ret = nsfb->surface_rtns->finalise(nsfb); + free(nsfb->surface_rtns); free(nsfb); + return ret; } -- cgit v1.2.3