From 86e4ecb99fa626a389cee96fb034c8c5b1c0121b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Nov 2020 17:44:24 +0100 Subject: Use C11 if possible --- zix/btree.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'zix') diff --git a/zix/btree.c b/zix/btree.c index 3dc2d57..302ab87 100644 --- a/zix/btree.c +++ b/zix/btree.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2019 David Robillard + Copyright 2011-2020 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -49,6 +49,11 @@ struct ZixBTreeNodeImpl { ZixBTreeNode* children[ZIX_BTREE_INODE_VALS + 1]; // Nonexistent for leaves }; +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) +static_assert(sizeof(ZixBTreeNode) == ZIX_BTREE_PAGE_SIZE, ""); +#endif + typedef struct { ZixBTreeNode* node; unsigned index; @@ -99,7 +104,11 @@ print_tree(const ZixBTreeNode* parent, const ZixBTreeNode* node, int level) ZIX_PRIVATE ZixBTreeNode* zix_btree_node_new(const bool leaf) { +#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \ + (defined(__cplusplus) && __cplusplus >= 201103L)) assert(sizeof(ZixBTreeNode) == ZIX_BTREE_PAGE_SIZE); +#endif + ZixBTreeNode* node = (ZixBTreeNode*)malloc(sizeof(ZixBTreeNode)); if (node) { node->is_leaf = leaf; -- cgit v1.2.1