projects
/
oweals
/
tinc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2764532
)
New function: xmalloc_and_zero, which initialises the allocated memory
author
Ivo Timmermans
<ivo@lychnis.net>
Thu, 16 Nov 2000 18:06:39 +0000
(18:06 +0000)
committer
Ivo Timmermans
<ivo@lychnis.net>
Thu, 16 Nov 2000 18:06:39 +0000
(18:06 +0000)
to all zeroes.
lib/xmalloc.c
patch
|
blob
|
history
diff --git
a/lib/xmalloc.c
b/lib/xmalloc.c
index 150b1aa7b65acdf3074b907ff1da7355038b7a4b..037fab87e2d6d9e4e1ab68e1cb89e9f9874c4889 100644
(file)
--- a/
lib/xmalloc.c
+++ b/
lib/xmalloc.c
@@
-94,6
+94,21
@@
xmalloc (n)
return p;
}
+/* Allocate N bytes of memory dynamically, and set it all to zero. */
+
+void *
+xmalloc_and_zero (n)
+ size_t n;
+{
+ void *p;
+
+ p = malloc (n);
+ if (p == 0)
+ xalloc_fail ((int)n);
+ memset (p, '\0', n);
+ return p;
+}
+
/* Change the size of an allocated block of memory P to N bytes,
with error checking.
If P is NULL, run xmalloc. */