Skip to content

Commit 1c07312

Browse files
committed
Use a different struct type for key types
This should help to identify cases where the Key and Value types are mixed up.
1 parent c60fd4a commit 1c07312

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/alt-value-type.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,25 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2323
-DTEST_ALTERNATE_VALUE_TYPES, this file will be included to define
2424
different types and confirm the library still builds. */
2525

26+
typedef struct {
27+
void *ptr;
28+
int v;
29+
} StructType2;
30+
2631
typedef struct {
2732
int a, b;
2833
} StructType;
2934

3035
#define STRUCT_TYPE_NULL {0, 0}
36+
#define STRUCT_TYPE2_NULL {(void *) 0, 0}
3137

3238
typedef StructType ArrayListValue;
3339
#define ARRAY_LIST_NULL STRUCT_TYPE_NULL
3440

35-
typedef StructType AVLTreeKey;
41+
typedef StructType2 AVLTreeKey;
3642
typedef StructType AVLTreeValue;
3743
#define AVL_TREE_NULL STRUCT_TYPE_NULL
44+
3845
typedef StructType BinaryHeapValue;
3946
#define BINARY_HEAP_NULL STRUCT_TYPE_NULL
4047

@@ -44,7 +51,8 @@ typedef StructType BinomialHeapValue;
4451
typedef StructType BloomFilterValue;
4552
#define BLOOM_FILTER_NULL STRUCT_TYPE_NULL
4653

47-
typedef StructType HashTableKey;
54+
typedef StructType2 HashTableKey;
55+
#define HASH_TABLE_KEY_NULL STRUCT_TYPE2_NULL
4856
typedef StructType HashTableValue;
4957
#define HASH_TABLE_NULL STRUCT_TYPE_NULL
5058

@@ -54,7 +62,7 @@ typedef StructType ListValue;
5462
typedef StructType QueueValue;
5563
#define QUEUE_NULL STRUCT_TYPE_NULL
5664

57-
typedef StructType RBTreeKey;
65+
typedef StructType2 RBTreeKey;
5866
typedef StructType RBTreeValue;
5967
#define RB_TREE_NULL STRUCT_TYPE_NULL
6068

0 commit comments

Comments
 (0)