1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-02-02 02:41:35 +00:00

Adjust hcmalloc to be the same as calloc

calloc is almost equivalent to malloc + memset(0) except that it's faster with big allocations because of OS trickery. It also protects against integer overflow and throws a null pointer on overflow whereas malloc does not.
This commit is contained in:
neheb 2017-10-01 17:46:59 -07:00 committed by Rosen Penev
parent 822ae7b9a9
commit baeb51ad38

View File

@ -23,16 +23,8 @@ void *hccalloc (const size_t nmemb, const size_t sz)
void *hcmalloc (const size_t sz)
{
void *p = malloc (sz);
if (p == NULL)
{
fprintf (stderr, "%s\n", MSG_ENOMEM);
return (NULL);
}
memset (p, 0, sz);
//calloc is faster than malloc with big allocations, so just use that.
void *p = hccalloc (sz, 1);
return (p);
}