aboutsummaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorokan2015-03-28 23:12:47 +0000
committerokan2015-03-28 23:12:47 +0000
commit9bb42946a8791addade91b9e9379f94b144429f7 (patch)
treeb25fc6d5b689346d70e6ed6da0e53631bfbba475 /xmalloc.c
parentbb5e4d99f201e4ec5894c69664775998925ad2d0 (diff)
downloadcwm-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.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 94f0691..21a65d7 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -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)
{