summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-19 17:02:18 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-19 17:02:18 +0000
commit81a7e0cbe9851c2388e53950a6db3e75b1156ead (patch)
tree6e0749ea07a0bd9ecdb7b246ae6d267dfab1067a /frontends
parentcdde777d9cf157460201c59c5cc05c7479c3f830 (diff)
downloadnetsurf-81a7e0cbe9851c2388e53950a6db3e75b1156ead.tar.gz
netsurf-81a7e0cbe9851c2388e53950a6db3e75b1156ead.tar.bz2
Change some AllocVecs to mallocs and FreeVecs to free
Need to be careful with ASPrintf
Diffstat (limited to 'frontends')
-rw-r--r--frontends/amiga/arexx.c3
-rw-r--r--frontends/amiga/bitmap.c4
-rw-r--r--frontends/amiga/clipboard.c11
-rw-r--r--frontends/amiga/download.c13
-rwxr-xr-xfrontends/amiga/memory.c22
-rw-r--r--frontends/amiga/memory.h6
6 files changed, 41 insertions, 18 deletions
diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c
index ad2d23713..cdb12c200 100644
--- a/frontends/amiga/arexx.c
+++ b/frontends/amiga/arexx.c
@@ -42,7 +42,6 @@
#include "amiga/hotlist.h"
#include "amiga/tree.h"
#include "amiga/libs.h"
-#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/theme.h"
@@ -272,7 +271,7 @@ RXHOOKF(rx_open)
{
if(!gw) return;
- dln = ami_misc_allocvec_clear(sizeof(struct dlnode), 0);
+ dln = calloc(1, sizeof(struct dlnode));
dln->filename = strdup((char *)cmd->ac_ArgList[3]);
dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]);
dln->node.ln_Type = NT_USER;
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 7609d9451..d612abf05 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -113,7 +113,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
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->pixdata = ami_memory_clear_alloc(width*height*4, 0xff);
bitmap->width = width;
bitmap->height = height;
@@ -170,7 +170,7 @@ void amiga_bitmap_destroy(void *bitmap)
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
- FreeVec(bm->pixdata);
+ ami_memory_clear_free(bm->pixdata);
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 4933f59e7..73f471fda 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -45,7 +45,6 @@
#include "amiga/iff_cset.h"
#include "amiga/iff_dr2d.h"
#include "amiga/menu.h"
-#include "amiga/memory.h"
#include "amiga/utf8.h"
#define ID_UTF8 MAKE_ID('U','T','F','8')
@@ -114,10 +113,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
case 0:
if(ci_new) {
- ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_next->ci_Next = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_next->ci_Next;
} else {
- ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_new = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_new;
}
@@ -128,10 +127,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
default:
if(ci_new) {
- ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_next->ci_Next = calloc(1, sizeof(struct CollectionItem), 0);
ci_next = ci_next->ci_Next;
} else {
- ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_new = calloc(1, sizeof(struct CollectionItem), 0);
ci_next = ci_new;
}
@@ -166,7 +165,7 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
if(ci_new) {
free(ci_curr->ci_Data);
- FreeVec(ci_curr);
+ free(ci_curr);
}
} while ((ci_curr = ci_next));
diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c
index 0750e5e83..3d9528c4d 100644
--- a/frontends/amiga/download.c
+++ b/frontends/amiga/download.c
@@ -64,7 +64,6 @@
#include "amiga/file.h"
#include "amiga/iff_dr2d.h"
#include "amiga/libs.h"
-#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
@@ -101,7 +100,7 @@ static struct gui_download_window *gui_download_window_create(download_context *
char *dl_filename = ami_utf8_easy(download_context_get_filename(ctx));
APTR va[3];
- dw = ami_misc_allocvec_clear(sizeof(struct gui_download_window), 0);
+ dw = calloc(1, sizeof(struct gui_download_window), 0);
if(gui && (!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url)))
{
@@ -123,13 +122,13 @@ static struct gui_download_window *gui_download_window_create(download_context *
AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size))
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
}
else
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
}
@@ -146,7 +145,7 @@ static struct gui_download_window *gui_download_window_create(download_context *
if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0)))
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
@@ -261,7 +260,7 @@ static void gui_download_window_done(struct gui_download_window *dw)
free(dln->filename);
Remove((struct Node *)dln);
- FreeVec(dln);
+ free(dln);
}
FClose(dw->fh);
@@ -344,7 +343,7 @@ void ami_free_download_list(struct List *dllist)
free(node->node.ln_Name);
free(node->filename);
Remove((struct Node *)node);
- FreeVec((struct Node *)node);
+ free((struct Node *)node);
}while((node=nnode));
}
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index 874f8521e..567f4f5c9 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -25,6 +25,28 @@
ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */
#endif
+/* Special clear (ie. non-zero), which is different on OS3 and 4 */
+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
+}
+
void *ami_misc_allocvec_clear(int size, UBYTE value)
{
#ifdef __amigaos4__
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index 1c51f3081..e74f795c3 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -21,7 +21,11 @@
#include <exec/types.h>
-/* Standard memory allocation */
+/* Alloc/free a block cleared to non-zero */
+void *ami_memory_clear_alloc(size_t size, UBYTE value);
+void ami_memory_clear_free(void *p);
+
+/* Standard memory allocation - to be removed */
void *ami_misc_allocvec_clear(int size, UBYTE value);
/* Itempool cross-compatibility */