1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

replace: Use memset_s for ZERO_* macros

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2018-12-03 15:31:30 +01:00 committed by Andrew Bartlett
parent 255117a14f
commit 3611f18f13

View File

@ -808,23 +808,27 @@ typedef unsigned long long ptrdiff_t ;
/**
* Zero a structure.
*/
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
#define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(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)
#define ZERO_STRUCTP(x) do { \
if ((x) != NULL) { \
memset_s((char *)(x), sizeof(*(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)))
#define ZERO_STRUCTPN(x) memset_s((char *)(x), sizeof(*(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))
#define ZERO_ARRAY(x) memset_s((char *)(x), sizeof(x), 0, sizeof(x))
/**
* Work out how many elements there are in a static array.