Re: [AD] Patches to add an _al_ustrdup() function (4.3.10)

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


On 2008-10-22, Colin Ward <lists@xxxxxxxxxx> wrote:
> Hi all.
> 
> In my continuing seek and destroy effort on memory leaks exposed by my
> memory tracking class, I have added an internal use only _al_ustrdup()
> function.  A lot of internal code was using ustrdup() to allocate strings
> and was then freeing it with _AL_FREE().  This is no good because it uses
> mismatching allocation and deallocation functions.  ustrdup() should only
> be used by external code, which then uses free() to free the result. 
> Conversely, all internal code should use _al_ustrdup() and the matching
> _AL_FREE().  The attached patches update the code to do this.
> 
> aintern.diff is the patch to add the _al_ustrdup() function prototype to
> allegro/internal/aintern.h.
> unicode.diff is the patch to add the _al_ustrdup() function implementation
> to src/unicode.c.
> 
> The rest of the patches fix up the files that call ustrdup() so that they
> call the proper _al_strdup() function.

Thanks, committed.

(In the future, generate patches in a single file so I don't have to extract
so many attachments.  Also, some of the indentation was off.  I fixed
some remaining calls in src/win.)

Out of curiousity, how does your memory tracker work?  In the 4.3 branch we
don't actually allow the user to set the underlying functions for _AL_MALLOC
and _AL_FREE (and I forgot about that previously).  They're only there
because at one stage we needed to be able to merge changes between the 4.3
and 4.9 branches and aligning 4.3 with 4.9 made that easier.

Peter





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