From e6b827979b3bb28a82101fe1211c809af112e987 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 29 Jan 2016 19:39:37 +0000 Subject: Allocate bitmap structures using an itempool --- amiga/bitmap.c | 15 ++++++++++++--- amiga/bitmap.h | 5 +++++ amiga/gui.c | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 986f4261f..28c229b06 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -52,13 +52,16 @@ enum { AMI_NSBM_PALETTEMAPPED }; +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 = AllocVecTagList(sizeof(struct bitmap), NULL); + + if(pool_bitmap == NULL) pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap)); + + 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); @@ -128,7 +131,7 @@ void amiga_bitmap_destroy(void *bitmap) bm->native_mask = NULL; bm->dto = NULL; - FreeVec(bm); + ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap)); bm = NULL; } } @@ -557,6 +560,12 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, } } +void ami_bitmap_fini(void) +{ + if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap); + pool_bitmap = NULL; +} + static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) { struct redraw_context ctx = { diff --git a/amiga/bitmap.h b/amiga/bitmap.h index aba359783..78d6c0d68 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -54,6 +54,11 @@ 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); +/** + * Cleanup bitmap allocations + */ +void ami_bitmap_fini(void); + /** * Create a bitmap. * diff --git a/amiga/gui.c b/amiga/gui.c index c73f0d117..c7f920f2b 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -5681,6 +5681,7 @@ int main(int argc, char** argv) FreeSysObject(ASOT_PORT, schedulermsgport); ami_object_fini(); + ami_bitmap_fini(); ami_libs_close(); return RETURN_OK; -- cgit v1.2.3