void *xcalloc(size_t, size_t);
void *xrealloc(void *, size_t);
void *xmemdup(const void *, size_t);
+char *xmemdup0(const char *, size_t);
char *xstrdup(const char *);
char *xasprintf(const char *format, ...) PRINTF_FORMAT(1, 2);
return p;
}
+char *
+xmemdup0(const char *p_, size_t length)
+{
+ char *p = xmalloc(length + 1);
+ memcpy(p, p_, length);
+ p[length] = '\0';
+ return p;
+}
+
char *
xstrdup(const char *s)
{
- return xmemdup(s, strlen(s) + 1);
+ return xmemdup0(s, strlen(s));
}
char *