aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-05 16:32:34 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-05 16:32:34 +0200
commite31c1d4a9f78c4e31fda1f98fe349b33abdd01a2 (patch)
tree61df772a93f7f21af7c715ddd4b9a3f1a50e0509 /src/include
parent1437556645417e6302862845e7ebcbd4c9908357 (diff)
downloadgnunet-e31c1d4a9f78c4e31fda1f98fe349b33abdd01a2.tar.gz
gnunet-e31c1d4a9f78c4e31fda1f98fe349b33abdd01a2.zip
GNUNET_free_non_null -> GNUNET_free
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_common.h31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 68993b51d..b2f99cd55 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -770,6 +770,12 @@ GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p);
770 770
771 771
772/** 772/**
773 * Forward declaration to make compiler happy depending on include order.
774 */
775struct GNUNET_PeerIdentity;
776
777
778/**
773 * @ingroup logging 779 * @ingroup logging
774 * Convert a peer identity to a string (for printing debug messages). 780 * Convert a peer identity to a string (for printing debug messages).
775 * This is one of the very few calls in the entire API that is 781 * This is one of the very few calls in the entire API that is
@@ -1275,6 +1281,7 @@ GNUNET_is_zero_ (const void *a,
1275#define GNUNET_malloc_large(size) \ 1281#define GNUNET_malloc_large(size) \
1276 GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) 1282 GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
1277 1283
1284
1278/** 1285/**
1279 * @ingroup memory 1286 * @ingroup memory
1280 * Wrapper around realloc. Reallocates size bytes of memory. 1287 * Wrapper around realloc. Reallocates size bytes of memory.
@@ -1287,6 +1294,7 @@ GNUNET_is_zero_ (const void *a,
1287#define GNUNET_realloc(ptr, size) \ 1294#define GNUNET_realloc(ptr, size) \
1288 GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) 1295 GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
1289 1296
1297
1290/** 1298/**
1291 * @ingroup memory 1299 * @ingroup memory
1292 * Wrapper around free. Frees the memory referred to by ptr. 1300 * Wrapper around free. Frees the memory referred to by ptr.
@@ -1294,40 +1302,27 @@ GNUNET_is_zero_ (const void *a,
1294 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free_nz. 1302 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free_nz.
1295 * 1303 *
1296 * @param ptr location where to free the memory. ptr must have 1304 * @param ptr location where to free the memory. ptr must have
1297 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. 1305 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed.
1298 */ 1306 */
1299#define GNUNET_free_nz(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__) 1307#define GNUNET_free_nz(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
1300 1308
1309
1301/** 1310/**
1302 * @ingroup memory 1311 * @ingroup memory
1303 * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL. 1312 * Wrapper around free. Frees the memory referred to by ptr and sets ptr to NULL.
1304 * Note that it is generally better to free memory that was 1313 * Note that it is generally better to free memory that was
1305 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free. 1314 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free.
1306 * 1315 *
1316 * @a ptr will be set to NULL. Use #GNUNET_free_nz() if @a ptr is not an L-value.
1317 *
1307 * @param ptr location where to free the memory. ptr must have 1318 * @param ptr location where to free the memory. ptr must have
1308 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. 1319 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed.
1309 */ 1320 */
1310#define GNUNET_free(ptr) do { \ 1321#define GNUNET_free(ptr) do { \
1311 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ 1322 GNUNET_xfree_ (ptr, __FILE__, __LINE__); \
1312 ptr = NULL; \ 1323 ptr = NULL; \
1313} while (0) 1324} while (0)
1314 1325
1315/**
1316 * @ingroup memory
1317 * Free the memory pointed to by ptr if ptr is not NULL.
1318 * Equivalent to `if (NULL != ptr) GNUNET_free(ptr)`.
1319 *
1320 * @param ptr the location in memory to free
1321 */
1322#define GNUNET_free_non_null(ptr) \
1323 do \
1324 { \
1325 void *__x__ = ptr; \
1326 if (NULL != __x__) \
1327 { \
1328 GNUNET_free (__x__); \
1329 } \
1330 } while (0)
1331 1326
1332/** 1327/**
1333 * @ingroup memory 1328 * @ingroup memory