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:
parent
822ae7b9a9
commit
baeb51ad38
12
src/memory.c
12
src/memory.c
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user