r22298: move ZERO_*, ARRAY_SIZE and PTR_DIFF macros into libreplace
authorStefan Metzmacher <metze@samba.org>
Tue, 17 Apr 2007 08:03:29 +0000 (08:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:19:24 +0000 (12:19 -0500)
metze

source/include/smb_macros.h
source/lib/replace/README
source/lib/replace/replace.h
source/nsswitch/winbind_nss_config.h

index d696db3d3acc2f51af2dba23507af1d0c1b1fded..2b596d3c6b8182a40ffe4134bc3c192e50ee09ff 100644 (file)
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
 #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))
-
-/* 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 */
 #ifdef DEVELOPER
 #define SMB_ASSERT(b) ( (b) ? (void)0 : \
index c2de560314a6995f696b626e326478c736e1baec..77558b2ca96718f95c3e58a950b0697f1c685e70 100644 (file)
@@ -86,6 +86,12 @@ __STRINGSTRING
 MIN
 MAX
 QSORT_CAST
+ZERO_STRUCT
+ZERO_STRUCTP
+ZERO_STRUCTPN
+ZERO_ARRAY
+ARRAY_SIZE
+PTR_DIFF
 
 Headers:
 stdint.h
index 840b448d24b35008efd3e1e3a5eba1ef801e4b49..b96356ac4670c2e4b76e0458986f8fdf50629a30 100644 (file)
@@ -451,6 +451,35 @@ typedef int bool;
 #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
index d595631362b27c15f4f2ab3d9f6c5b4bca3f1322..c36d4e723255426716488447366c934fa5547735 100644 (file)
@@ -103,18 +103,6 @@ typedef int BOOL;
 #endif  /* don't lie.  If we don't have it, then don't use it */
 #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) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); }
-#endif
-
 /* Some systems (SCO) treat UNIX domain sockets as FIFOs */
 
 #ifndef S_IFSOCK