[pacman-dev] [PATCH] Clean up MD5 code.

Xavier shiningxc at gmail.com
Thu Aug 16 14:37:47 EDT 2007


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?




More information about the pacman-dev mailing list