/* Some non-POSIX realloc()s don't cope with realloc(NULL,sz) */
if (!ptr) {
- return mh_xcalloc((size_t) 1, size);
+ return mh_xcalloc(1, size);
}
if (size == 0) {
adios(EX_SOFTWARE, NULL, "Tried to realloc 0 bytes");
}
/*
+** Free a pointer and set it to NULL.
+*/
+void
+mh_free0(void * ptr)
+{
+ void ** p;
+ p = ptr;
+ free(*p);
+ *p = NULL;
+}
+
+/*
** Return the present working directory, if the current directory does not
** exist, or is too long, make / the pwd.
*/
/* Copy s1 and free it */
if (s1) {
memcpy(cp, s1, len1);
- free(s1);
+ mh_free0(&s1);
}
/* Copy s2 */
if (!getanswer(cp)) {
done_callback(EX_CANTCREAT);
}
- free(cp);
+ mh_free0(&cp);
} else if (autocreate == -1) {
/* do not create, so exit */
done_callback(EX_CANTCREAT);