diff options
author | Ran Benita <ran234@gmail.com> | 2012-03-24 00:29:33 +0200 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2012-03-27 14:15:11 +0100 |
commit | 813ddf255d076efe65c953ff5dc6521839ab052b (patch) | |
tree | 115827089ab31c80e34734c7dfe187e0ae59d274 /src/utils.h | |
parent | f08ce9b71b08e8db846780b7187124da53ba1c3c (diff) | |
download | libxkbcommon-813ddf255d076efe65c953ff5dc6521839ab052b.tar.gz libxkbcommon-813ddf255d076efe65c953ff5dc6521839ab052b.tar.bz2 libxkbcommon-813ddf255d076efe65c953ff5dc6521839ab052b.zip |
Silence -Wcast-qual warnings
There are some cases where we must free a string with a const qualifier.
Add a macro UNCONSTIFY to trick the compiler into silencing the warning
in the cases where we know what we're doing.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index cbf3552..630fa48 100644 --- a/src/utils.h +++ b/src/utils.h @@ -40,6 +40,13 @@ extern void * recalloc(void *ptr, size_t old_size, size_t new_size); +/* + * We sometimes malloc strings and then expose them as const char*'s. This + * macro is used when we free these strings in order to avoid -Wcast-qual + * errors. + */ +#define UNCONSTIFY(const_ptr) ((void *)(uintptr_t)(const_ptr)) + #define uTypedAlloc(t) malloc(sizeof(t)) #define uTypedCalloc(n, t) calloc((n), sizeof(t)) #define uTypedRealloc(pO, n, t) realloc((pO), (n) * sizeof(t)) |