X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/f9e640f1c0dc5d4fbffde207f2a4b0350d1a0019..e97bd37b6c4e291467ca0d2f627deb1fa66fb79e:/mandoc_aux.c diff --git a/mandoc_aux.c b/mandoc_aux.c index 28a6e2f7..db593e44 100644 --- a/mandoc_aux.c +++ b/mandoc_aux.c @@ -1,7 +1,7 @@ -/* $Id: mandoc_aux.c,v 1.6 2015/10/11 21:12:54 schwarze Exp $ */ +/* $Id: mandoc_aux.c,v 1.10 2017/06/12 19:05:47 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons - * Copyright (c) 2014 Ingo Schwarze + * Copyright (c) 2014, 2015, 2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,7 +19,9 @@ #include +#if HAVE_ERR #include +#endif #include #include #include @@ -28,9 +30,6 @@ #include "mandoc.h" #include "mandoc_aux.h" -#if !HAVE_PROGNAME -const char *mandoc_progname; -#endif int mandoc_asprintf(char **dest, const char *fmt, ...) @@ -72,7 +71,6 @@ mandoc_malloc(size_t size) void * mandoc_realloc(void *ptr, size_t size) { - ptr = realloc(ptr, size); if (ptr == NULL) err((int)MANDOCLEVEL_SYSERR, NULL); @@ -82,20 +80,28 @@ mandoc_realloc(void *ptr, size_t size) void * mandoc_reallocarray(void *ptr, size_t num, size_t size) { - ptr = reallocarray(ptr, num, size); if (ptr == NULL) err((int)MANDOCLEVEL_SYSERR, NULL); return ptr; } +void * +mandoc_recallocarray(void *ptr, size_t oldnum, size_t num, size_t size) +{ + ptr = recallocarray(ptr, oldnum, num, size); + if (ptr == NULL) + err((int)MANDOCLEVEL_SYSERR, NULL); + return ptr; +} + char * mandoc_strdup(const char *ptr) { char *p; p = strdup(ptr); - if (ptr == NULL) + if (p == NULL) err((int)MANDOCLEVEL_SYSERR, NULL); return p; }