mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Allocate generic list objects using itempools
TODO: Allocate the attached structures also using itempools
This commit is contained in:
parent
c2bd86ca96
commit
7e7ea09000
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005,2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2005, 2008, 2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -18,7 +18,9 @@
|
||||
|
||||
#include "amiga/os3support.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <proto/exec.h>
|
||||
#include <exec/lists.h>
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user