30 Jul 2012 21:06
[PATCH] common/util.h: dodgy non-__GNUC__ p_delete
Arvydas Sidorenko <asido4 <at> gmail.com>
2012-07-30 19:06:05 GMT
2012-07-30 19:06:05 GMT
I assume nobody have tried to compile Awesome with GNU uncompatible
compiler for ages and thus non-__GNUC__ p_delete version got
overlooked for quite some time.
First of all, a problem I see is that it assigns void** to a variable
of type void* and then dereferences the same void* variable.
None of the compilers I am aware of will let you go through this
without an error.
And second of all, lets have one portable p_delete.
Signed-off-by: Arvydas Sidorenko <asido4 <at> gmail.com>
---
common/util.h | 24 ++++++------------------
1 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/common/util.h b/common/util.h
index a2f9e49..cf4500f 100644
--- a/common/util.h
+++ b/common/util.h
<at> <at> -80,31 +80,19 <at> <at>
} \
} while (0)
+#define p_delete(mem_p) \
+ do { \
+ void **__ptr = (void **) (mem_p); \
+ free(*__ptr); \
+ *(void **)__ptr = NULL; \
+ } while (0)
#ifdef __GNUC__
(Continue reading)
RSS Feed