X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Fxmalloc.c;h=037fab87e2d6d9e4e1ab68e1cb89e9f9874c4889;hp=ce1888d8254ce1bd24056f2ec47114c9f550f354;hb=699e159a7a1711034f1d16d68ad1974a82e12dfc;hpb=3d218a31145cf6a4c625ed287cdf3f99e4fd9a03 diff --git a/lib/xmalloc.c b/lib/xmalloc.c index ce1888d8..037fab87 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -20,6 +20,7 @@ #endif #include +#include #if STDC_HEADERS # include @@ -86,8 +87,6 @@ xmalloc (n) size_t n; { void *p; - extern char*cp_file; - extern int cp_line; p = malloc (n); if (p == 0) @@ -95,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. */