Patch attempting to take care of some memory errors

Håkan Kvist <[email protected]> Sat, 24 Feb 2007 16:12:12 +0100
Newsgroups gmane.network.centericq
Message-ID <[email protected]>
Hi.

I have fiddled a little bit with the code (see attatched patch).

What I have looked at is how memory is allocated and deallocated.

I have trid to make sure that:

 * Memory allocated by malloc() is released by free()

 * Memory allocated by new[] is released by delete[]

 * Memory allocated by new is released by delete


One example is:
    auto_ptr<char> msg(strdup("free for chat"));

This might look okay at first sight, but it will call free[] when
attempting to free the pointer, wich is not correct (since strdup is a
C function and returned pointer must be deallocated by free()).


There was one or two places where memory was accessed outside the
allocated space.


There was one or two places where uninitialized memory where read.


However, there is still work to do regarding leakage of memory, but
valgrind[1] gives a much nicer printout now :-)


regards
Håkan

[1] http://www.valgrind.org
_______________________________________________
Cicq mailing list
Cicq-xGejAJT2w6wWP6gT/[email protected]
http://mailman.linuxpl.org/mailman/listinfo/cicq
Questions? Check the FAQ first: http://centericq.de/faq/