From: | Bart King |
Date: | 15 Aug 2000 at 14:23:16 |
Subject: | Re: memory allocation fcns |
At 11-Aug-00 23:28:37, Jack York <jyork@voyager.net> wrote:
[memory pools]
> By allocating a lot of small chunks do you mean like nodes in a list or
> variables that are declared for use in a function (like string buffers)?
Yes, this is a good example of effective usage for pooled memory
allocations. However, it is very common practice (especially if you are
writing portable code) to just create the buffers on the stack/function
entry e.g.
char mybuffer[256];
> The only advantage I can see to malloc is the related realloc. Is
> there something similar native to the Amiga that will allow the
> resizing of allocated memory?
malloc() is cross-platform - that is the advantage of it. If you do
mem = malloc(1024); compile on the Amiga, Windows, Linux, Mac,
Dreamcast, you will get 1024 bytes of memory.
In regards to realloc(), the Amiga does not offer a standard function
to achieve this. Below is a modified code fragment taken from my
custom memory handling routines to show you what realloc() effectively
does.
==8<==
void *MEM_Realloc(void *Mem, int NewSize)
{
}
==8<==
As you can see, memory allocation routines are nothing special :)