From: lurchi Date: Thu, 28 Jun 2018 22:04:25 +0000 (+0200) Subject: Allow dereferenced pointers as input for GNUNET_array_grow and GNUNET_xgrow X-Git-Tag: v0.11.0~322^2~106^2~1^2~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7c04b23c8c80e06257706facf74a92bfec7a9914;p=oweals%2Fgnunet.git Allow dereferenced pointers as input for GNUNET_array_grow and GNUNET_xgrow This is now possible: char ***server_addrs = NULL unsigned int len = 0 GNUNET_array_append (*server_addrs, len, "8.8.8.8"); --- diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index b4bf5b0aa..1b982cc15 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -1074,7 +1074,7 @@ GNUNET_ntoh_double (double d); * @param tsize the target size for the resulting vector, use 0 to * free the vector (then, arr will be NULL afterwards). */ -#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, sizeof(arr[0]), &size, tsize, __FILE__, __LINE__) +#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&(arr), sizeof((arr)[0]), &size, tsize, __FILE__, __LINE__) /** * @ingroup memory @@ -1089,7 +1089,7 @@ GNUNET_ntoh_double (double d); * array size * @param element the element that will be appended to the array */ -#define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); arr[size-1] = element; } while(0) +#define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); (arr)[size-1] = element; } while(0) /** * @ingroup memory