From 7e7ea09000c9386dfa4db75be3ea6c49ab203cfd Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 22 Jan 2016 18:40:40 +0000 Subject: Allocate generic list objects using itempools TODO: Allocate the attached structures also using itempools --- amiga/gui.c | 4 ++++ amiga/misc.c | 4 ++-- amiga/object.c | 26 +++++++++++++++++++++++--- amiga/object.h | 4 ++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index 58e7938fd..2521acbfd 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -3049,6 +3049,8 @@ static void gui_quit(void) FreeVec(current_user_faviconcache); FreeVec(current_user); + ami_object_fini(); + ami_libs_close(); } @@ -5497,6 +5499,8 @@ int main(int argc, char** argv) /* Open splash window */ Object *splash_window = ami_gui_splash_open(); + ami_object_init(); + if (ami_open_resources() == false) { /* alloc message ports */ ami_misc_fatal_error("Unable to allocate resources"); ami_gui_splash_close(splash_window); diff --git a/amiga/misc.c b/amiga/misc.c index 9100120c2..97e9f9f1c 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -52,10 +52,10 @@ APTR ami_misc_itempool_create(int size) ASOITEM_MFlags, MEMF_PRIVATE, ASOITEM_ItemSize, size, ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT, - ASOITEM_GCParameter, 50, + ASOITEM_GCParameter, 100, TAG_DONE); #else - return CreatePool(MEMF_ANY, 2 * size, size); + return CreatePool(MEMF_ANY, 20 * size, size); #endif } diff --git a/amiga/object.c b/amiga/object.c index 7d935943e..aab66bb43 100755 --- a/amiga/object.c +++ b/amiga/object.c @@ -1,5 +1,5 @@ /* - * Copyright 2005,2008 Chris Young + * Copyright 2005, 2008, 2016 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -18,7 +18,9 @@ #include "amiga/os3support.h" +#include #include +#include #include #include @@ -35,6 +37,21 @@ #define NewnsList NewList #endif +APTR pool_nsobj = NULL; + +bool ami_object_init(void) +{ + pool_nsobj = ami_misc_itempool_create(sizeof(struct nsObject)); + + if(pool_nsobj == NULL) return false; + else return true; +} + +void ami_object_fini(void) +{ + ami_misc_itempool_delete(pool_nsobj); +} + /* Slightly abstract MinList initialisation */ void ami_NewMinList(struct MinList *list) { @@ -61,8 +78,10 @@ struct nsObject *AddObject(struct MinList *objlist, ULONG otype) { struct nsObject *dtzo; - dtzo = (struct nsObject *)ami_misc_allocvec_clear(sizeof(struct nsObject), 0); + dtzo = (struct nsObject *)ami_misc_itempool_alloc(pool_nsobj, sizeof(struct nsObject)); + if(dtzo == NULL) return NULL; + memset(dtzo, 0, sizeof(struct nsObject)); AddTail((struct List *)objlist,(struct Node *)dtzo); dtzo->Type = otype; @@ -81,7 +100,7 @@ static void DelObjectInternal(struct nsObject *dtzo, BOOL free_obj) if(dtzo->callback != NULL) dtzo->callback(dtzo->objstruct); if(dtzo->objstruct && free_obj) FreeVec(dtzo->objstruct); if(dtzo->dtz_Node.ln_Name) free(dtzo->dtz_Node.ln_Name); - FreeVec(dtzo); + ami_misc_itempool_free(pool_nsobj, dtzo, sizeof(struct nsObject)); dtzo = NULL; } @@ -110,3 +129,4 @@ void FreeObjList(struct MinList *objlist) FreeVec(objlist); } + diff --git a/amiga/object.h b/amiga/object.h index 85cbb6d52..6ea9bd1b1 100755 --- a/amiga/object.h +++ b/amiga/object.h @@ -58,5 +58,9 @@ void FreeObjList(struct MinList *objlist); /** List abstraction as OS3 appears to have problems with NewMinList() **/ struct MinList *ami_AllocMinList(void); void ami_NewMinList(struct MinList *list); + +/** Initialisation for itempool **/ +bool ami_object_init(void); +void ami_object_fini(void); #endif -- cgit v1.2.3