return p;
}
+/* Duplicate a NUL-terminated string, exit on failure. */
+char *mh_xstrdup(const char *src)
+{
+ size_t n;
+ char *dest;
+
+ n = strlen(src) + 1; /* Ignore possibility of overflow. */
+ dest = mh_xmalloc(n);
+ memcpy(dest, src, n);
+
+ return dest;
+}
+
+/* Call free(3), if ptr isn't NULL. */
+void mh_xfree(void *ptr)
+{
+ if (ptr)
+ free(ptr); /* Some very old platforms can't cope with NULL. */
+}
+
/*
* Return the present working directory, if the current directory does not
* exist, or is too long, make / the pwd.
char *
pwd(void)
{
- register char *cp;
+ char *cp;
static char curwd[PATH_MAX];
if (!getcwd (curwd, PATH_MAX)) {