[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: add GNUNET_freez for #6186
From: |
gnunet |
Subject: |
[gnunet] branch master updated: add GNUNET_freez for #6186 |
Date: |
Fri, 17 Apr 2020 18:25:58 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 6b89b84d2 add GNUNET_freez for #6186
6b89b84d2 is described below
commit 6b89b84d2781a774adbadf272eb90785889b8407
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Apr 17 18:21:17 2020 +0200
add GNUNET_freez for #6186
---
src/include/gnunet_common.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
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
@@ -1291,6 +1291,20 @@ GNUNET_is_zero_ (const void *a,
*/
#define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
+/**
+ * @ingroup memory
+ * Wrapper around free. Frees the memory referred to by ptr and sets ptr to
NULL.
+ * Note that it is generally better to free memory that was
+ * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0)
instead of #GNUNET_freez.
+ *
+ * @param ptr location where to free the memory. ptr must have
+ * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or
#GNUNET_array_grow earlier.
+ */
+#define GNUNET_freez(ptr) do { \
+ GNUNET_xfree_ (ptr, __FILE__, __LINE__); \
+ ptr = NULL; \
+} while (0)
+
/**
* @ingroup memory
* Free the memory pointed to by ptr if ptr is not NULL.
@@ -1302,7 +1316,7 @@ GNUNET_is_zero_ (const void *a,
do \
{ \
void *__x__ = ptr; \
- if (__x__ != NULL) \
+ if (NULL != __x__) \
{ \
GNUNET_free (__x__); \
} \
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: add GNUNET_freez for #6186,
gnunet <=