测试嵌入式代码时,我发现我需要一个键值存储,其键和值均为(void *)。 (测试套件在x86_64上运行。)
通常,我存储的数据应该与结构的实例相关联(在测试过程中),但是我不想将数据添加到结构本身。即密钥将是结构的地址。
(I know I could #ifdef TESTING
around extra fields in structs, but it makes them less readable.)
我不需要高性能,O(N)可以。
I could write myself a linked-list, with next
, key
and value
at each node, but I thought I would ask first.