summaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-09-29 14:25:49 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-09-29 14:25:49 +0000
commit1e316cfc7c0623038f850de1a2f2688497c51914 (patch)
treec9f3d324701eaade5f8463ee4ffe0bad523451ab /xmalloc.c
parent653ee721df4b0464803d6cba46376b4fcbd09b82 (diff)
Lose intermediate handling (unused). Change argument parsing to work properly over multiple buffers by saving a copy of the argument (we can't just save off/len since the buffer may vanish at any point).
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 478e5f0e..dff43189 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
-/* $Id: xmalloc.c,v 1.2 2007-07-25 23:13:18 nicm Exp $ */
+/* $Id: xmalloc.c,v 1.3 2007-09-29 14:25:49 nicm Exp $ */
/*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -70,6 +70,18 @@ ensure_size(void *buf, size_t *len, size_t nmemb, size_t size)
}
char *
+xmemstrdup(const char *buf, size_t len)
+{
+ char *s;
+
+ s = xmalloc(len + 1);
+ memcpy(s, buf, len);
+ s[len] = '\0';
+
+ return (s);
+}
+
+char *
xstrdup(const char *s)
{
void *ptr;