aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-04-17 18:21:17 +0200
committerChristian Grothoff <christian@grothoff.org>2020-04-17 18:21:17 +0200
commit6b89b84d2781a774adbadf272eb90785889b8407 (patch)
tree76ee4b5739ceac2ed36508c7ef9bebccd6fee29d /src/include
parentc894cf82d59f81529c8f50edec91ca27bd39023d (diff)
downloadgnunet-6b89b84d2781a774adbadf272eb90785889b8407.tar.gz
gnunet-6b89b84d2781a774adbadf272eb90785889b8407.zip
add GNUNET_freez for #6186
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_common.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 6a4e21823..78aeb3de7 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -1293,6 +1293,20 @@ GNUNET_is_zero_ (const void *a,
1293 1293
1294/** 1294/**
1295 * @ingroup memory 1295 * @ingroup memory
1296 * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL.
1297 * Note that it is generally better to free memory that was
1298 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_freez.
1299 *
1300 * @param ptr location where to free the memory. ptr must have
1301 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
1302 */
1303#define GNUNET_freez(ptr) do { \
1304 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \
1305 ptr = NULL; \
1306} while (0)
1307
1308/**
1309 * @ingroup memory
1296 * Free the memory pointed to by ptr if ptr is not NULL. 1310 * Free the memory pointed to by ptr if ptr is not NULL.
1297 * Equivalent to `if (NULL != ptr) GNUNET_free(ptr)`. 1311 * Equivalent to `if (NULL != ptr) GNUNET_free(ptr)`.
1298 * 1312 *
@@ -1302,7 +1316,7 @@ GNUNET_is_zero_ (const void *a,
1302 do \ 1316 do \
1303 { \ 1317 { \
1304 void *__x__ = ptr; \ 1318 void *__x__ = ptr; \
1305 if (__x__ != NULL) \ 1319 if (NULL != __x__) \
1306 { \ 1320 { \
1307 GNUNET_free (__x__); \ 1321 GNUNET_free (__x__); \
1308 } \ 1322 } \