summaryrefslogtreecommitdiff
path: root/usr.bin/file/xmalloc.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 18:51:12 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-06-17 18:51:12 +0000
commit7f7ca105212cc3adc77a0b0575d0ad215a45d156 (patch)
tree6669618087e072072333bc2e252fe465ca0573b6 /usr.bin/file/xmalloc.c
parent24014939b5171dda05f1f565ad52021eec8cddce (diff)
Use strdup in xstrdup from Fritjof Bornebusch. While here, remove xfree
which is unused.
Diffstat (limited to 'usr.bin/file/xmalloc.c')
-rw-r--r--usr.bin/file/xmalloc.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/usr.bin/file/xmalloc.c b/usr.bin/file/xmalloc.c
index 857bcd91569..243da4c52dc 100644
--- a/usr.bin/file/xmalloc.c
+++ b/usr.bin/file/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.1 2015/04/24 16:24:11 nicm Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.2 2015/06/17 18:51:11 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -65,24 +65,13 @@ xreallocarray(void *ptr, size_t nmemb, size_t size)
return new_ptr;
}
-void
-xfree(void *ptr)
-{
- if (ptr == NULL)
- errx(1, "xfree: NULL pointer given as argument");
- free(ptr);
-}
-
char *
xstrdup(const char *str)
{
- size_t len;
char *cp;
- len = strlen(str) + 1;
- cp = xmalloc(len);
- if (strlcpy(cp, str, len) >= len)
- errx(1, "xstrdup: string truncated");
+ if ((cp = strdup(str)) == NULL)
+ err(1, "xstrdup");
return cp;
}