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

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


On 24/10/2008, you wrote:
> 

[Snip]

>> 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.)

Ok, thanks for that.  Will submit a single patch in the future and will keep
an eye on the white space (my text editor has a habit of changing spaces to
tabs white space).

> 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.

It is a c++ class that exists as a single global instance and intercepts
new/delete and malloc/free and adds them to a list of allocations.  Upon
exit of the program, after main() has exited, the class's global destructor
is the last thing executed and it checks to see if the list is empty.  If
there is anything on the list it will display a warning.  It can also do
checking for overwriting over the end of allocated blocks and accessing
memory after it has been freed.  It is VERY useful for finding memory leaks
in software, as you have noticed by the patches I have been submitting -
there are more to come.  :-)

For Allegro it has a secondary use, which is that many Allegro games leak a
LOT of memory at shutdown.  People just don't free things, which isn't a
problem on most operating systems, but on Amiga OS it is we don't have
resource tracking (for historical reasons).  So a simplified version of the
tracker will have to be present in the Amiga OS port of Allegro.

I was thinking that rather than it being in c++ maybe once I do my commit we
might want to convert it to standard C (easily done) and use it for memory
tracking in debug builds of Allegro?  It is completely platform independent
and is terribly useful for finding memory leaks.

How do you mean that the user can't change the underlying functions in the
4.3 branch?  I am using 4.3.10 and in include/allegro/internal/aintern.h
there is the following:

/* malloc wrappers */
/* The 4.3 branch uses the following macro names to allow the user to
customise
 * the memory management routines.  We don't have that feature in 4.2, but
we
 * use the same macros names in order to reduce divergence of the codebases.
 */
#define _AL_MALLOC(SIZE)         (_al_malloc(SIZE))
#define _AL_MALLOC_ATOMIC(SIZE)  (_al_malloc(SIZE))
#define _AL_FREE(PTR)     
#define _AL_REALLOC(PTR, SIZE)   (_al_realloc(PTR, SIZE))

I just comment these out and change them to use my routines.  I'm not sure
what you mean when you say it can't be done.

-- 
/-------------------------------------------------------------------\
[Hitman/Code HQ - 6502/z80/68000/604e/80x86/ARM coder - Amiga rulez!]
[VZ-200/VIC-20/MZ-700/c16/c64*10/c128*8/Plus-4/CPC464/CD32/500*2    ]
[600/1000/1200*2/A4000/SNES/N64/Dreamcast/Athlon 1100/AmigaOne      ]
[Assembly Language: The most fun you can have with your clothes on! ]
\-------------------------------------------------------------------/





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