aboutsummaryrefslogtreecommitdiff
path: root/xmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/xmalloc.c b/xmalloc.c
index fcb8481d..22ea3540 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -81,6 +81,16 @@ xstrdup(const char *str)
return cp;
}
+char *
+xstrndup(const char *str, size_t maxlen)
+{
+ char *cp;
+
+ if ((cp = strndup(str, maxlen)) == NULL)
+ fatalx("xstrndup: %s", strerror(errno));
+ return cp;
+}
+
int
xasprintf(char **ret, const char *fmt, ...)
{