#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "xmalloc.h"
static void
xmalloc_default_error_handler(int err)
return ptr;
}
-void
-xfree(void *ptr)
+char *
+xstrdup(const char *s)
{
- free(ptr);
- ptr = NULL;
+ size_t len = strlen(s);
+ void *new;
+
+ new = xmalloc_inc(len, 1);
+ if(new == NULL)
+ return NULL;
+
+ return (char *)memcpy(new, s, len + 1);
}