diff options
author | Jeremy Allison <jra@samba.org> | 2008-10-20 16:38:25 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-10-20 16:38:25 -0700 |
commit | 29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9 (patch) | |
tree | 761e1b6c8172470d651c7760806ce5081f5ee55f /lib/util/memory.h | |
parent | 6aba3516769b944e7960d27f10799bb8a8898d2d (diff) | |
parent | cefe4c66970b8ca243595cdb940a7c1a26765a08 (diff) | |
download | samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.tar.gz samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.tar.bz2 samba-29c9b88e2bb5d3f585e7aa591870e8b39a0d23c9.zip |
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
Diffstat (limited to 'lib/util/memory.h')
-rw-r--r-- | lib/util/memory.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/util/memory.h b/lib/util/memory.h index de01492aa2..cfc13ab836 100644 --- a/lib/util/memory.h +++ b/lib/util/memory.h @@ -88,6 +88,31 @@ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) #endif +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#ifndef discard_const +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) +#endif + +/** Type-safe version of discard_const */ +#ifndef discard_const_p +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#endif #endif /* _SAMBA_MEMORY_H_ */ |