svn commit: samba r22369 - in branches/SAMBA_4_0/source/lib/util: .
metze at samba.org
metze at samba.org
Thu Apr 19 12:51:04 GMT 2007
Author: metze
Date: 2007-04-19 12:51:04 +0000 (Thu, 19 Apr 2007)
New Revision: 22369
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22369
Log:
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
Modified:
branches/SAMBA_4_0/source/lib/util/util.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/util/util.h
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util.h 2007-04-19 09:26:03 UTC (rev 22368)
+++ branches/SAMBA_4_0/source/lib/util/util.h 2007-04-19 12:51:04 UTC (rev 22369)
@@ -82,4 +82,45 @@
#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_ */
More information about the samba-cvs
mailing list