From fa198865e1af85f2868fceea03e64dc46ada9a1c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 13 May 2018 21:18:49 +0200 Subject: [PATCH] add missing #define --- src/nat/gnunet-helper-nat-client.c | 11 +++++++++++ src/nat/gnunet-helper-nat-server.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/nat/gnunet-helper-nat-client.c b/src/nat/gnunet-helper-nat-client.c index 9768dd856..359e529b0 100644 --- a/src/nat/gnunet-helper-nat-client.c +++ b/src/nat/gnunet-helper-nat-client.c @@ -66,6 +66,17 @@ #define ICMP_TIME_EXCEEDED 11 #endif +/** + * Call memcpy() but check for @a n being 0 first. In the latter + * case, it is now safe to pass NULL for @a src or @a dst. + * Unlike traditional memcpy(), returns nothing. + * + * @param dst destination of the copy, may be NULL if @a n is zero + * @param src source of the copy, may be NULL if @a n is zero + * @param n number of bytes to copy + */ +#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0) + /** * Must match IP given in the server. */ diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c index f35649152..b8f499b4d 100644 --- a/src/nat/gnunet-helper-nat-server.c +++ b/src/nat/gnunet-helper-nat-server.c @@ -70,6 +70,17 @@ #define ICMP_TIME_EXCEEDED 11 #endif +/** + * Call memcpy() but check for @a n being 0 first. In the latter + * case, it is now safe to pass NULL for @a src or @a dst. + * Unlike traditional memcpy(), returns nothing. + * + * @param dst destination of the copy, may be NULL if @a n is zero + * @param src source of the copy, may be NULL if @a n is zero + * @param n number of bytes to copy + */ +#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0) + /** * Should we print some debug output? */ -- 2.25.1