diff options
author | okan | 2015-03-28 23:12:47 +0000 |
---|---|---|
committer | okan | 2015-03-28 23:12:47 +0000 |
commit | 9bb42946a8791addade91b9e9379f94b144429f7 (patch) | |
tree | b25fc6d5b689346d70e6ed6da0e53631bfbba475 /xmalloc.c | |
parent | bb5e4d99f201e4ec5894c69664775998925ad2d0 (diff) | |
download | cwm-9bb42946a8791addade91b9e9379f94b144429f7.tar.gz |
Introduce a xreallocarray and convert a few xcalloc instances that do
not require zero'ing.
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xmalloc.c,v 1.14 2015/01/19 14:54:16 okan Exp $ + * $OpenBSD: xmalloc.c,v 1.15 2015/03/28 23:12:47 okan Exp $ */ #include <sys/types.h> @@ -61,6 +61,18 @@ xcalloc(size_t no, size_t siz) return(p); } +void * +xreallocarray(void *ptr, size_t nmemb, size_t size) +{ + void *p; + + p = reallocarray(ptr, nmemb, size); + if (p == NULL) + errx(1, "xreallocarray: out of memory (new_size %zu bytes)", + nmemb * size); + return(p); +} + char * xstrdup(const char *str) { |