]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-compat-util.h
provide --color option for all ref-filter users
[thirdparty/git.git] / git-compat-util.h
index 51ba4e6b3b7822915e3867722ec0b54b314111f7..047172d173c495d7e723a00db5d563113978f917 100644 (file)
@@ -808,6 +808,12 @@ extern char *xgetcwd(void);
 extern FILE *fopen_for_writing(const char *path);
 extern FILE *fopen_or_warn(const char *path, const char *mode);
 
+/*
+ * FREE_AND_NULL(ptr) is like free(ptr) followed by ptr = NULL. Note
+ * that ptr is used twice, so don't pass e.g. ptr++.
+ */
+#define FREE_AND_NULL(p) do { free(p); (p) = NULL; } while (0)
+
 #define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
 #define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))