Re: [AD] mode-list updates.]

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Doug Eleveld <deleveld@xxxxxxxxxx> wrote:

> So you end up having to be like:
>
> /* Try to reallocate */
> void * newmem = realloc(mem, newsize);
> if (newmem)
>    mem = newmem;
>
> To make sure you don't have a leak and that you can free it eventually.
It does make realloc code less clean that it
> appears it could be.
>
> Sorry if this is all too obvious...

You said it: obvious. However you gave me a good idea. What if i provide an
al_realloc() which works exactly like libc realloc() just that it's
behaviour is guaranteed? in other words: if ptr=NULL -> malloc, if size=0 ->
free, otherwise call realloc and if failure -> free.

Sincerely Henrik Stokseth.
-----------------------------------------------------------------------
E-mail: hstokset@xxxxxxxxxx  Homepage: http://hstokset.n3.net




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/