projects
/
fio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
8a1db9a
)
smalloc: add zeroing scalloc() variant
author
Jens Axboe
<axboe@fb.com>
Thu, 6 Nov 2014 22:19:31 +0000
(15:19 -0700)
committer
Jens Axboe
<axboe@fb.com>
Thu, 6 Nov 2014 22:19:31 +0000
(15:19 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
smalloc.c
patch
|
blob
|
blame
|
history
smalloc.h
patch
|
blob
|
blame
|
history
diff --git
a/smalloc.c
b/smalloc.c
index 5fe0b6f7e57d11cdade9f103d9e8ff9dd5cbf7c1..1ba9353518813179fd3e277ae2cbeeec20a43129 100644
(file)
--- 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 f9a5e410fae79b570973a708c95f713912d8e40c..4b551e3e4be3fd979462371a4c866c349e2bb04e 100644
(file)
--- 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);