From b41685208f25a906b8a08809e67c2a1a2ec153d9 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 21 Jan 2016 20:42:49 +0000 Subject: Revert "alloc bitmap structures using itempools" This reverts commit 0cc19b10fcd9f43bb4c9d83654d2d07cad139b12. This caused memory leakage, as the memory pool is removed before the core has destroyed all the bitmaps. --- amiga/bitmap.c | 43 +++++++++++-------------------------------- amiga/bitmap.h | 3 --- amiga/gui.c | 18 ++++-------------- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 5ba74020c..6984d3e0c 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -44,28 +44,21 @@ #include "amiga/misc.h" #include "amiga/rtg.h" -static APTR pool_bitmap = NULL; - /* exported function documented in amiga/bitmap.h */ void *amiga_bitmap_create(int width, int height, unsigned int state) { struct bitmap *bitmap; + + bitmap = ami_misc_allocvec_clear(sizeof(struct bitmap), 0); + if(bitmap) + { + bitmap->pixdata = ami_misc_allocvec_clear(width*height*4, 0xff); + bitmap->width = width; + bitmap->height = height; - bitmap = ami_misc_itempool_alloc(pool_bitmap, sizeof(struct bitmap)); - if(bitmap == NULL) return NULL; - - bitmap->pixdata = ami_misc_allocvec_clear(width*height*4, 0xff); - bitmap->width = width; - bitmap->height = height; - - if(state & BITMAP_OPAQUE) bitmap->opaque = true; - else bitmap->opaque = false; - - bitmap->nativebm = NULL; - bitmap->nativebmwidth = 0; - bitmap->nativebmheight = 0; - bitmap->native_mask = NULL; - bitmap->dto = NULL; + if(state & BITMAP_OPAQUE) bitmap->opaque = true; + else bitmap->opaque = false; + } return bitmap; } @@ -116,7 +109,7 @@ void amiga_bitmap_destroy(void *bitmap) bm->native_mask = NULL; bm->dto = NULL; - ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap)); + FreeVec(bm); bm = NULL; } } @@ -589,20 +582,6 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) return NSERROR_OK; } -void amiga_bitmap_fini(void) -{ - if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap); -} - -bool amiga_bitmap_init(void) -{ - if((pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap)))) { - return true; - } else { - return false; - } -} - static struct gui_bitmap_table bitmap_table = { .create = amiga_bitmap_create, .destroy = amiga_bitmap_destroy, diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 4607d9f99..ff1b01c6e 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -53,9 +53,6 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap); struct bitmap *ami_bitmap_from_datatype(char *filename); -void amiga_bitmap_fini(void); -bool amiga_bitmap_init(void); - #ifndef __amigaos4__ void ami_bitmap_argb_to_rgba(struct bitmap *bm); #endif diff --git a/amiga/gui.c b/amiga/gui.c index 9aedad86f..58e7938fd 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -405,21 +405,8 @@ bool ami_locate_resource(char *fullpath, const char *file) return found; } -/* Frees stuff opened by ami_open_resources() */ -static void ami_resources_free(void) -{ - FreeSysObject(ASOT_PORT, appport); - FreeSysObject(ASOT_PORT, sport); - FreeSysObject(ASOT_PORT, schedulermsgport); - - FreeStringClass(urlStringClass); - amiga_bitmap_fini(); -} - static bool ami_open_resources(void) { - if(!amiga_bitmap_init()) return false; - urlStringClass = MakeStringClass(); if(!(appport = AllocSysObjectTags(ASOT_PORT, @@ -3047,10 +3034,13 @@ static void gui_quit(void) LOG("Freeing scheduler resources"); ami_schedule_free(); - ami_resources_free(); + FreeSysObject(ASOT_PORT, appport); + FreeSysObject(ASOT_PORT, sport); + FreeSysObject(ASOT_PORT, schedulermsgport); ami_file_req_free(); ami_openurl_close(); + FreeStringClass(urlStringClass); FreeObjList(window_list); -- cgit v1.2.3