fix semantics for kore_calloc().

We were not returning zeroed out memory from kore_calloc() which goes
against what calloc() does. Skip performance for now and simply just
memset() the returned pointer from kore_malloc().

This should be sufficient enough for now.
This commit is contained in:
Joris Vink 2017-02-27 19:46:59 -08:00
parent 3e84502235
commit 27da1dd741
1 changed files with 8 additions and 1 deletions

View File

@ -135,10 +135,17 @@ kore_realloc(void *ptr, size_t len)
void *
kore_calloc(size_t memb, size_t len)
{
void *ptr;
size_t total;
if (SIZE_MAX / memb < len)
fatal("kore_calloc(): memb * len > SIZE_MAX");
return (kore_malloc(memb * len));
total = memb * len;
ptr = kore_malloc(total);
memset(ptr, 0, total);
return (ptr);
}
void