summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-20 16:30:33 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2016-11-20 16:30:33 (GMT)
commit17128fd0ad119c801a17e06da1fd8b351fb17f21 (patch)
treec29a1c223ed860c1eec3201645a4b1d47a6ee109
parentb3042f6c1fcb708d8663f4ab51865fe6a1f8bec3 (diff)
downloadnetsurf-17128fd0ad119c801a17e06da1fd8b351fb17f21.tar.gz
netsurf-17128fd0ad119c801a17e06da1fd8b351fb17f21.tar.bz2
Move ItemPool compatiblity into the header and rename
-rw-r--r--frontends/amiga/gui.c10
-rwxr-xr-xfrontends/amiga/memory.c57
-rw-r--r--frontends/amiga/memory.h28
-rwxr-xr-xfrontends/amiga/object.c8
-rw-r--r--frontends/amiga/plotters.c8
5 files changed, 37 insertions, 74 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index ecc36fa..e5b5c59 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -3829,7 +3829,7 @@ gui_window_create(struct browser_window *bw,
NewList(&g->dllist);
g->deferred_rects = NewObjList();
- g->deferred_rects_pool = ami_misc_itempool_create(sizeof(struct rect));
+ g->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
g->bw = bw;
g->scale = browser_window_get_scale(bw);
@@ -4492,7 +4492,7 @@ static void gui_window_destroy(struct gui_window *g)
ami_free_download_list(&g->dllist);
FreeObjList(g->deferred_rects);
- ami_misc_itempool_delete(g->deferred_rects_pool);
+ ami_memory_itempool_delete(g->deferred_rects_pool);
gui_window_stop_throbber(g);
cur_gw = NULL;
@@ -4705,7 +4705,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
rect->x0, rect->y0, rect->x1, rect->y1);
}
nnode=(struct nsObject *)GetSucc((struct Node *)node);
- ami_misc_itempool_free(g->deferred_rects_pool, node->objstruct, sizeof(struct rect));
+ ami_memory_itempool_free(g->deferred_rects_pool, node->objstruct, sizeof(struct rect));
DelObjectNoFree(node);
} while((node = nnode));
@@ -4739,7 +4739,7 @@ static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_re
(new_rect->x1 >= rect->x1) &&
(new_rect->y1 >= rect->y1)) {
LOG("Removing queued redraw that is a subset of new box redraw");
- ami_misc_itempool_free(mempool, node->objstruct, sizeof(struct rect));
+ ami_memory_itempool_free(mempool, node->objstruct, sizeof(struct rect));
DelObjectNoFree(node);
/* Don't return - we might find more */
}
@@ -4756,7 +4756,7 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *restr
if(ami_gui_window_update_box_deferred_check(g->deferred_rects, rect,
g->deferred_rects_pool)) {
- deferred_rect = ami_misc_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect));
+ deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect));
CopyMem(rect, deferred_rect, sizeof(struct rect));
nsobj = AddObject(g->deferred_rects, AMINS_RECT);
nsobj->objstruct = deferred_rect;
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index 7a34f7a..901d616 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -23,68 +23,13 @@
#ifndef __amigaos4__
ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */
-#endif
-/* Special clear (ie. non-zero), which is different on OS3 and 4 */
+/* Special clear (ie. non-zero) */
void *ami_memory_clear_alloc(size_t size, UBYTE value)
{
-#ifdef __amigaos4__
- return AllocVecTags(size, AVT_ClearWithValue, value, TAG_DONE);
-#else
void *mem = malloc(size);
if (mem) memset(mem, value, size);
return mem;
-#endif
}
-
-/* Free special clear (ie. non-zero) area, which is different on OS3 and 4 */
-void ami_memory_clear_free(void *p)
-{
-#ifdef __amigaos4__
- FreeVec(p);
-#else
- free(p);
#endif
-}
-
-APTR ami_misc_itempool_create(int size)
-{
-#ifdef __amigaos4__
- return AllocSysObjectTags(ASOT_ITEMPOOL,
- ASOITEM_MFlags, MEMF_PRIVATE,
- ASOITEM_ItemSize, size,
- ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT,
- ASOITEM_GCParameter, 100,
- TAG_DONE);
-#else
- return CreatePool(MEMF_ANY, 20 * size, size);
-#endif
-}
-
-void ami_misc_itempool_delete(APTR pool)
-{
-#ifdef __amigaos4__
- FreeSysObject(ASOT_ITEMPOOL, pool);
-#else
- DeletePool(pool);
-#endif
-}
-
-APTR ami_misc_itempool_alloc(APTR pool, int size)
-{
-#ifdef __amigaos4__
- return ItemPoolAlloc(pool);
-#else
- return AllocPooled(pool, size);
-#endif
-}
-
-void ami_misc_itempool_free(APTR restrict pool, APTR restrict item, int size)
-{
-#ifdef __amigaos4__
- ItemPoolFree(pool, item);
-#else
- FreePooled(pool, item, size);
-#endif
-}
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index 63452f6..a3b6b5e 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -31,13 +31,31 @@
#endif
/* Alloc/free a block cleared to non-zero */
+#ifdef __amigaos4__
+#define ami_memory_clear_alloc(s,v) AllocVecTags(s, AVT_ClearWithValue, v, TAG_DONE)
+#define ami_memory_clear_free(p) FreeVec(p)
+#else
void *ami_memory_clear_alloc(size_t size, UBYTE value);
-void ami_memory_clear_free(void *p);
+#define ami_memory_clear_free(p) free(p)
+#endif
/* Itempool cross-compatibility */
-APTR ami_misc_itempool_create(int size);
-void ami_misc_itempool_delete(APTR pool);
-APTR ami_misc_itempool_alloc(APTR pool, int size);
-void ami_misc_itempool_free(APTR pool, APTR item, int size);
+#ifdef __amigaos4__
+#define ami_memory_itempool_create(s) AllocSysObjectTags(ASOT_ITEMPOOL, \
+ ASOITEM_MFlags, MEMF_PRIVATE, \
+ ASOITEM_ItemSize, s, \
+ ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT, \
+ ASOITEM_GCParameter, 100, \
+ TAG_DONE)
+#define ami_memory_itempool_delete(p) FreeSysObject(ASOT_ITEMPOOL, p)
+#define ami_memory_itempool_alloc(p,s) ItemPoolAlloc(p)
+#define ami_memory_itempool_free(p,i,s) ItemPoolFree(p,i)
+#else
+#define ami_memory_itempool_create(s) CreatePool(MEMF_ANY, 20 * s, s)
+#define ami_memory_itempool_delete(p) DeletePool(p)
+#define ami_memory_itempool_alloc(p,s) AllocPooled(p, s)
+#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
#endif
+#endif //AMIGA_MEMORY_H
+
diff --git a/frontends/amiga/object.c b/frontends/amiga/object.c
index c729e4a..2ebca75 100755
--- a/frontends/amiga/object.c
+++ b/frontends/amiga/object.c
@@ -41,7 +41,7 @@ static APTR pool_nsobj = NULL;
bool ami_object_init(void)
{
- pool_nsobj = ami_misc_itempool_create(sizeof(struct nsObject));
+ pool_nsobj = ami_memory_itempool_create(sizeof(struct nsObject));
if(pool_nsobj == NULL) return false;
else return true;
@@ -49,7 +49,7 @@ bool ami_object_init(void)
void ami_object_fini(void)
{
- ami_misc_itempool_delete(pool_nsobj);
+ ami_memory_itempool_delete(pool_nsobj);
}
/* Slightly abstract MinList initialisation */
@@ -78,7 +78,7 @@ struct nsObject *AddObject(struct MinList *objlist, ULONG otype)
{
struct nsObject *dtzo;
- dtzo = (struct nsObject *)ami_misc_itempool_alloc(pool_nsobj, sizeof(struct nsObject));
+ dtzo = (struct nsObject *)ami_memory_itempool_alloc(pool_nsobj, sizeof(struct nsObject));
if(dtzo == NULL) return NULL;
memset(dtzo, 0, sizeof(struct nsObject));
@@ -100,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) free(dtzo->objstruct);
if(dtzo->dtz_Node.ln_Name) free(dtzo->dtz_Node.ln_Name);
- ami_misc_itempool_free(pool_nsobj, dtzo, sizeof(struct nsObject));
+ ami_memory_itempool_free(pool_nsobj, dtzo, sizeof(struct nsObject));
dtzo = NULL;
}
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index f9fa62a..6bae634 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -193,7 +193,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
if((gg->palette_mapped == true) && (pool_pens == NULL)) {
- pool_pens = ami_misc_itempool_create(sizeof(struct ami_plot_pen));
+ pool_pens = ami_memory_itempool_create(sizeof(struct ami_plot_pen));
}
gg->apen = 0x00000000;
@@ -210,7 +210,7 @@ void ami_free_layers(struct gui_globals *gg)
init_layers_count--;
if((init_layers_count == 0) && (pool_pens != NULL)) {
- ami_misc_itempool_delete(pool_pens);
+ ami_memory_itempool_delete(pool_pens);
pool_pens = NULL;
}
@@ -256,7 +256,7 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr)
if(pen == -1) LOG("WARNING: Cannot allocate pen for ABGR:%lx", colr);
if((shared_pens != NULL) && (pool_pens != NULL)) {
- if((node = (struct ami_plot_pen *)ami_misc_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) {
+ if((node = (struct ami_plot_pen *)ami_memory_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) {
node->pen = pen;
AddTail((struct List *)shared_pens, (struct Node *)node);
}
@@ -280,7 +280,7 @@ void ami_plot_release_pens(struct MinList *shared_pens)
nnode = (struct ami_plot_pen *)GetSucc((struct Node *)node);
ReleasePen(scrn->ViewPort.ColorMap, node->pen);
Remove((struct Node *)node);
- ami_misc_itempool_free(pool_pens, node, sizeof(struct ami_plot_pen));
+ ami_memory_itempool_free(pool_pens, node, sizeof(struct ami_plot_pen));
} while((node = nnode));
glob->apen = 0x00000000;