summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-10-23 22:45:41 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-10-23 22:45:41 +0100
commit8e262181e6f85bc89dfed652d971a876c7e6e153 (patch)
tree3cdbf23af9f82cbb0487aa212b98b5c52a991085
parent730e6ce9eeb9393243a4e0fe4eed229bf5414bc2 (diff)
downloadlibnsfb-8e262181e6f85bc89dfed652d971a876c7e6e153.tar.gz
libnsfb-8e262181e6f85bc89dfed652d971a876c7e6e153.tar.bz2
When destroying framebuffer, ensure any cursor is destroyed.
-rw-r--r--include/cursor.h3
-rw-r--r--src/cursor.c10
-rw-r--r--src/libnsfb.c6
3 files changed, 19 insertions, 0 deletions
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;
}