16 Aug
2007
16 Aug
'07
6:37 p.m.
On Thu, Aug 16, 2007 at 01:36:31PM -0400, Dan McGee wrote:
2. Watch your mallocs, and use calloc when possible. You didn't allocate space for the null byte, so you were overrunning your buffers when you filled them and the free() failed when using mtrace(). I switched to calloc usage, and now use sprintf because this is a case where we can do that- it is faster and we aren't worried about running out of room. We then need to take care of the null byte ourselves, however.
Why is it better to use calloc? And when using calloc, is it still needed to set the null byte a second time?