lib:util: Sync memory.h with replace.h
authorAndreas Schneider <asn@samba.org>
Mon, 3 Dec 2018 14:37:03 +0000 (15:37 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 20 Dec 2018 11:16:40 +0000 (12:16 +0100)
We can't remove memory.h as this is a public header file. So we need to
duplicate them from replace.h

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/memory.h

index 0b87a97bd8e2c5bd64a555a695d0449b1081fcbe..3278f6b3c2178287abf49723aa2d20658fcd7b23 100644 (file)
  * Zero a structure.
  */
 #ifndef ZERO_STRUCT
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+#define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(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)
+#define ZERO_STRUCTP(x) do { \
+       if ((x) != NULL) { \
+               memset_s((char *)(x), sizeof(*(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)))
+#define ZERO_STRUCTPN(x) memset_s((char *)(x), sizeof(*(x)), 0, sizeof(*(x)))
 #endif
 
 /**
@@ -73,7 +77,7 @@
  * pointer.
  */
 #ifndef ZERO_ARRAY
-#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
+#define ZERO_ARRAY(x) memset_s((char *)(x), sizeof(x), 0, sizeof(x))
 #endif
 
 /**