svn commit: samba r22297 - in branches/SAMBA_4_0/source/lib: replace util

metze at samba.org metze at samba.org
Tue Apr 17 08:03:02 GMT 2007


Author: metze
Date: 2007-04-17 08:03:01 +0000 (Tue, 17 Apr 2007)
New Revision: 22297

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22297

Log:
move ZERO_*, ARRAY_SIZE and PTR_DIFF macros into libreplace

metze
Modified:
   branches/SAMBA_4_0/source/lib/replace/README
   branches/SAMBA_4_0/source/lib/replace/replace.h
   branches/SAMBA_4_0/source/lib/util/util.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/README
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/README	2007-04-17 07:45:54 UTC (rev 22296)
+++ branches/SAMBA_4_0/source/lib/replace/README	2007-04-17 08:03:01 UTC (rev 22297)
@@ -86,6 +86,12 @@
 MIN
 MAX
 QSORT_CAST
+ZERO_STRUCT
+ZERO_STRUCTP
+ZERO_STRUCTPN
+ZERO_ARRAY
+ARRAY_SIZE
+PTR_DIFF
 
 Headers:
 stdint.h

Modified: branches/SAMBA_4_0/source/lib/replace/replace.h
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.h	2007-04-17 07:45:54 UTC (rev 22296)
+++ branches/SAMBA_4_0/source/lib/replace/replace.h	2007-04-17 08:03:01 UTC (rev 22297)
@@ -451,6 +451,35 @@
 #define __location__ __FILE__ ":" __LINESTR__
 #endif
 
+/** 
+ * zero a structure 
+ */
+#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+
+/** 
+ * zero a structure given a pointer to the structure 
+ */
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
+
+/** 
+ * zero a structure given a pointer to the structure - no zero check 
+ */
+#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
+
+/* zero an array - note that sizeof(array) must work - ie. it must not be a
+   pointer */
+#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
+
+/**
+ * work out how many elements there are in a static array 
+ */
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+/** 
+ * pointer difference macro 
+ */
+#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
+
 #if MMAP_BLACKLIST
 #undef HAVE_MMAP
 #endif

Modified: branches/SAMBA_4_0/source/lib/util/util.h
===================================================================
--- branches/SAMBA_4_0/source/lib/util/util.h	2007-04-17 07:45:54 UTC (rev 22296)
+++ branches/SAMBA_4_0/source/lib/util/util.h	2007-04-17 08:03:01 UTC (rev 22297)
@@ -41,32 +41,7 @@
 #include "util/byteorder.h"
 #include "lib/util/util_proto.h"
 
-/** 
- * zero a structure 
- */
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
-
-/** 
- * zero a structure given a pointer to the structure 
- */
-#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
-
-/** 
- * zero a structure given a pointer to the structure - no zero check 
- */
-#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
-
-/** 
- * pointer difference macro 
- */
-#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
-
 /**
- * work out how many elements there are in a static array 
- */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
-/**
  * assert macros 
  */
 #define SMB_ASSERT(b) do { if (!(b)) { \



More information about the samba-cvs mailing list