From: Jens Axboe Date: Thu, 6 Nov 2014 22:19:31 +0000 (-0700) Subject: smalloc: add zeroing scalloc() variant X-Git-Tag: fio-2.1.14~13 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=544992f770de2b98481b980e463e0492c2f2763e smalloc: add zeroing scalloc() variant Signed-off-by: Jens Axboe --- diff --git a/smalloc.c b/smalloc.c index 5fe0b6f7..1ba93535 100644 --- a/smalloc.c +++ b/smalloc.c @@ -479,6 +479,17 @@ out: return NULL; } +void *scalloc(size_t nmemb, size_t size) +{ + void *ret; + + ret = smalloc(nmemb * size); + if (ret) + memset(ret, 0, nmemb * size); + + return ret; +} + char *smalloc_strdup(const char *str) { char *ptr; diff --git a/smalloc.h b/smalloc.h index f9a5e410..4b551e3e 100644 --- a/smalloc.h +++ b/smalloc.h @@ -2,6 +2,7 @@ #define FIO_SMALLOC_H extern void *smalloc(size_t); +extern void *scalloc(size_t, size_t); extern void sfree(void *); extern char *smalloc_strdup(const char *); extern void sinit(void);