kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 27da1dd7417bf81f7aa314e0d9110e4e8b7d7323
parent 3e84502235ba30c889948ecb40690d78101220fc
Author: Joris Vink <joris@coders.se>
Date:   Mon, 27 Feb 2017 19:46:59 -0800

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.

Diffstat:
src/mem.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/mem.c b/src/mem.c @@ -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