diff options
author | Simon McVittie <smcv@collabora.com> | 2022-09-15 15:30:44 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-09-15 16:46:59 +0000 |
commit | 57c9f99d780939dfe51865fd7c4a9764d4844d7f (patch) | |
tree | abe99e47b7e093c47fc451d6683bc6136ced48b6 /dbus | |
parent | e2f7256bbeb1c9d270b921b82a180abe2560ab52 (diff) | |
download | dbus-57c9f99d780939dfe51865fd7c4a9764d4844d7f.tar.gz |
mempool: Require C99 flexible arrays
dbus 1.15.x officially requires C99, so we can do this unconditionally
on the 1.15.x branch.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-mempool.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index 62bfc035..38c019a7 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -65,22 +65,6 @@ struct DBusFreedElement DBusFreedElement *next; /**< next element of the free list */ }; -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define HAVE_FLEXIBLE_ARRAYS -#elif defined(__GNUC__) || defined(_MSC_VER) -#define HAVE_ZERO_LENGTH_ARRAYS -#endif - -/** - * The dummy size of the variable-length "elements" - * field in DBusMemBlock - */ -#if defined(HAVE_FLEXIBLE_ARRAYS) || defined(HAVE_ZERO_LENGTH_ARRAYS) -#define ELEMENT_PADDING 0 -#else -#define ELEMENT_PADDING 4 -#endif - /** * Typedef for DBusMemBlock so the struct can recursively * point to itself. @@ -101,11 +85,7 @@ struct DBusMemBlock /* this is a long so that "elements" is aligned */ long used_so_far; /**< bytes of this block already allocated as elements. */ -#ifdef HAVE_FLEXIBLE_ARRAYS unsigned char elements[]; /**< the block data, actually allocated to required size */ -#else - unsigned char elements[ELEMENT_PADDING]; -#endif }; /** @@ -244,8 +224,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) * should vanish) */ - alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + - pool->element_size; + alloc_size = sizeof (DBusMemBlock) + pool->element_size; if (pool->zero_elements) block = dbus_malloc0 (alloc_size); @@ -310,7 +289,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) pool->element_size) == 0); } - alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + pool->block_size; + alloc_size = sizeof (DBusMemBlock) + pool->block_size; #ifdef DBUS_ENABLE_EMBEDDED_TESTS /* We save/restore the counter, so that memory pools won't |