diff options
author | Mike Hommey <mh@glandium.org> | 2012-04-20 08:38:42 +0200 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2012-04-23 11:43:44 -0700 |
commit | 461ad5c87ae5f89cd086e47b31372e9123dcfcdf (patch) | |
tree | 52b9c66d8931f4ad631582d037f1e500f35e259c /include/jemalloc/internal/ctl.h | |
parent | 40f514fd92d50320075bf9fd8748edb71092a1d8 (diff) | |
download | jemalloc-461ad5c87ae5f89cd086e47b31372e9123dcfcdf.tar.gz |
Avoid using a union for ctl_node_s
MSVC doesn't support C99, and as such doesn't support designated
initialization of structs and unions. As there is never a mix of
indexed and named nodes, it is pretty straightforward to use a
different type for each.
Diffstat (limited to 'include/jemalloc/internal/ctl.h')
-rw-r--r-- | include/jemalloc/internal/ctl.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/include/jemalloc/internal/ctl.h b/include/jemalloc/internal/ctl.h index a48d09f..c06b9af 100644 --- a/include/jemalloc/internal/ctl.h +++ b/include/jemalloc/internal/ctl.h @@ -2,6 +2,8 @@ #ifdef JEMALLOC_H_TYPES typedef struct ctl_node_s ctl_node_t; +typedef struct ctl_named_node_s ctl_named_node_t; +typedef struct ctl_indexed_node_s ctl_indexed_node_t; typedef struct ctl_arena_stats_s ctl_arena_stats_t; typedef struct ctl_stats_s ctl_stats_t; @@ -11,22 +13,23 @@ typedef struct ctl_stats_s ctl_stats_t; struct ctl_node_s { bool named; - union { - struct { - const char *name; - /* If (nchildren == 0), this is a terminal node. */ - unsigned nchildren; - const ctl_node_t *children; - } named; - struct { - const ctl_node_t *(*index)(const size_t *, size_t, - size_t); - } indexed; - } u; +}; + +struct ctl_named_node_s { + struct ctl_node_s node; + const char *name; + /* If (nchildren == 0), this is a terminal node. */ + unsigned nchildren; + const ctl_node_t *children; int (*ctl)(const size_t *, size_t, void *, size_t *, void *, size_t); }; +struct ctl_indexed_node_s { + struct ctl_node_s node; + const ctl_named_node_t *(*index)(const size_t *, size_t, size_t); +}; + struct ctl_arena_stats_s { bool initialized; unsigned nthreads; |