librpc:ndr: Add NDR_ZERO_STRUCT(P) macros
authorAndreas Schneider <asn@samba.org>
Wed, 13 Feb 2019 09:38:02 +0000 (10:38 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 14 Feb 2019 14:59:26 +0000 (15:59 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
librpc/ndr/libndr.h

index 1f0f3c227cfb989002b02f829f8bef0aabe6daa7..9c403319b6ed87f6db28d596914a5947534627ac 100644 (file)
@@ -411,6 +411,13 @@ enum ndr_compression_alg {
        if (unlikely(!(s))) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %s failed: %s\n", # s, __location__); \
 } while (0)
 
+#define NDR_ZERO_STRUCT(x) ndr_zero_memory(&(x), sizeof(x))
+#define NDR_ZERO_STRUCTP(x) do { \
+       if ((x) != NULL) { \
+               ndr_zero_memory((x), sizeof(*(x))); \
+       } \
+} while(0)
+
 /* these are used when generic fn pointers are needed for ndr push/pull fns */
 typedef enum ndr_err_code (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, const void *);
 typedef enum ndr_err_code (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *);