diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-04-19 12:51:04 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:51:08 -0500 |
commit | f21cdbc9425478674b1624f5d2b23c477f6de316 (patch) | |
tree | b0e697cee4b950f6110f21602943271901092c6e | |
parent | 52f655d689d937e7cd9de6cf3436de9ddbe9ecae (diff) | |
download | samba-f21cdbc9425478674b1624f5d2b23c477f6de316.tar.gz samba-f21cdbc9425478674b1624f5d2b23c477f6de316.tar.bz2 samba-f21cdbc9425478674b1624f5d2b23c477f6de316.zip |
r22369: add ZERO_STRUCT() ... macros to lib/util/util.h again
to fix the openchange build...
we need to remove them from libreplace, but I'll think about that
next week.
metze
(This used to be commit 2243142b46e20825339b4f6ed0e878c18e50e45f)
-rw-r--r-- | source4/lib/util/util.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index cfd77e5a13..f2531aaa85 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -82,4 +82,45 @@ extern const char *panic_action; #define strlen(x) valgrind_strlen(x) #endif +/** + * zero a structure + */ +#ifndef ZERO_STRUCT +#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) +#endif + +/** + * zero a structure given a pointer to the structure + */ +#ifndef ZERO_STRUCTP +#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) +#endif + +/** + * zero a structure given a pointer to the structure - no zero check + */ +#ifndef ZERO_STRUCTPN +#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x))) +#endif + +/* zero an array - note that sizeof(array) must work - ie. it must not be a + pointer */ +#ifndef ZERO_ARRAY +#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x)) +#endif + +/** + * work out how many elements there are in a static array + */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) +#endif + +/** + * pointer difference macro + */ +#ifndef PTR_DIFF +#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) +#endif + #endif /* _SAMBA_UTIL_H_ */ |