diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-12-15 13:41:58 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-12-15 13:41:58 +0200 |
commit | 20f6d481aabb9dcd4f38e486c80677f5a0d23f67 (patch) | |
tree | e4459ab595e0f8c6b5af8ef8be71091e75e8bcdf /system.h | |
parent | b4588a1202783dd9bbee594aa5aea022ccdd3fc9 (diff) | |
download | librpm-tizen-20f6d481aabb9dcd4f38e486c80677f5a0d23f67.tar.gz librpm-tizen-20f6d481aabb9dcd4f38e486c80677f5a0d23f67.tar.bz2 librpm-tizen-20f6d481aabb9dcd4f38e486c80677f5a0d23f67.zip |
Expose compiler warnings from freeing data declared as const
- _free() is just a wrapper to free() which additionally returns NULL
- add _constfree() for use in the cases where const is used to protect
malloced "read-only" data in long-lived otherwise exposed structures etc
Diffstat (limited to 'system.h')
-rw-r--r-- | system.h | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -234,17 +234,30 @@ typedef char * security_context_t; #endif /** - * Wrapper to free(3), hides const compilation noise, permit NULL, return NULL. + * Wrapper to free(3), permit NULL, return NULL. * @param p memory to free * @return NULL always */ static inline -void * _free(const void * p) +void * _free(void * p) { - if (p != NULL) free((void *)p); + if (p != NULL) free(p); return NULL; } +/** + * Wrapper to free(3), permit NULL, return NULL. + * For documenting cases where const is used to protect long-lived + * non-const data that's supposed to be freed. + * @param p memory to free + * @return NULL always + */ +static inline +void * _constfree(const void * p) +{ + if (p != NULL) free((void *)p); + return NULL; +} /* FIX: these are macros */ /** |