projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace free() with mh_free0()
[mmh]
/
sbr
/
utils.c
diff --git
a/sbr/utils.c
b/sbr/utils.c
index
2744581
..
f61456d
100644
(file)
--- a/
sbr/utils.c
+++ b/
sbr/utils.c
@@
-65,6
+65,18
@@
mh_xcalloc(size_t nmemb, size_t size)
}
/*
}
/*
+** 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.
*/
** Return the present working directory, if the current directory does not
** exist, or is too long, make / the pwd.
*/
@@
-119,7
+131,7
@@
add(char *s2, char *s1)
/* Copy s1 and free it */
if (s1) {
memcpy(cp, s1, len1);
/* Copy s1 and free it */
if (s1) {
memcpy(cp, s1, len1);
- free(s1);
+ mh_free0(&s1);
}
/* Copy s2 */
}
/* Copy s2 */
@@
-155,7
+167,7
@@
create_folder(char *folder, int autocreate, void (*done_callback)(int))
if (!getanswer(cp)) {
done_callback(EX_CANTCREAT);
}
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);
} else if (autocreate == -1) {
/* do not create, so exit */
done_callback(EX_CANTCREAT);