diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2013-02-21 23:10:36 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2013-02-21 23:10:36 +0000 |
commit | 70df2d197d308bebe5155600524bd3ac678dfab5 (patch) | |
tree | eaaae4ef64a3dc8fceacf12162f58c508552ecb7 /amiga | |
parent | 486593df35b7081afbfb79836a0f0ad196bcb648 (diff) | |
download | netsurf-70df2d197d308bebe5155600524bd3ac678dfab5.tar.gz netsurf-70df2d197d308bebe5155600524bd3ac678dfab5.tar.bz2 |
Attempt replacement of memory allocation functions with primitive working alternatives
Diffstat (limited to 'amiga')
-rw-r--r-- | amiga/Makefile.target | 3 | ||||
-rwxr-xr-x | amiga/alloc.c | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target index dc79479c5..b2e3db957 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -61,6 +61,7 @@ else ifeq ($(SUBTARGET),os3) LDFLAGS += -lpbl -liconv else + CFLAGS += -DAMIGA_NETSURF_REPLACE_ALLOC LDFLAGS += -lauto -lpbl -liconv endif endif @@ -80,7 +81,7 @@ S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \ sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \ datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \ stringview/stringview.c stringview/urlhistory.c \ - agclass/amigaguide_class.c + agclass/amigaguide_class.c alloc.c S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) # This is the final source build list diff --git a/amiga/alloc.c b/amiga/alloc.c new file mode 100755 index 000000000..062efab6c --- /dev/null +++ b/amiga/alloc.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <proto/exec.h> + +#ifdef AMIGA_NETSURF_REPLACE_ALLOC +#define nsa_malloc malloc +#define nsa_calloc calloc +#define nsa_realloc realloc +#define nsa_free free +#endif + +void nsa_free(void *p) { + if(p == NULL) return; + UBYTE *mem = p - 4; + FreeVec(mem); +} +void *nsa_malloc(size_t s) { + UBYTE *mem = AllocVec(s + 4, MEMF_PRIVATE); + *mem = s; + return mem + 4; +} +void *nsa_calloc(size_t nelem, size_t nsize) { + UBYTE *mem = AllocVec((nelem * nsize) + 4, MEMF_PRIVATE | MEMF_CLEAR); + *mem = (nelem * nsize); + return mem + 4; +} +void *nsa_realloc(void *p, size_t s) { + void *newptr; + ULONG old_size = *((UBYTE *)p - 4); + newptr = nsa_malloc(s); + memcpy(newptr, p, old_size); + nsa_free(p); + return newptr; +} |