From 4ab5b3f6f5c841ab8c2202e838979a0d6df91530 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 23 Sep 2021 09:48:32 +0200 Subject: Found bug/leak thanks to sanitizer: #define i_key_csptr int // correct, auto setup cmp, keydel, keyfrom. #define i_key csptr_int // wrong unless cmp, keydel, keyfrom is also defined (correctly). --- examples/new_sptr.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/new_sptr.c b/examples/new_sptr.c index 186f6e7b..be70e00c 100644 --- a/examples/new_sptr.c +++ b/examples/new_sptr.c @@ -23,8 +23,7 @@ void Person_del(Person* p) { #include #define i_tag iptr -#define i_key csptr_int -#define i_cmp csptr_int_compare +#define i_key_csptr int #include int main(void) { @@ -32,14 +31,14 @@ int main(void) { c_autovar (csptr_person q = csptr_person_clone(p), csptr_person_del(&q)) // share the pointer { printf("%s %s. uses: %zu\n", q.get->name.str, q.get->last.str, *q.use_count); + } - c_auto (csset_iptr, map) { - csset_iptr_insert(&map, csptr_int_make(2021)); - csset_iptr_insert(&map, csptr_int_make(2033)); + c_auto (csset_iptr, map) { + csset_iptr_insert(&map, csptr_int_make(2021)); + csset_iptr_insert(&map, csptr_int_make(2033)); - c_foreach (i, csset_iptr, map) - printf(" %d", *i.ref->get); - puts(""); - } + c_foreach (i, csset_iptr, map) + printf(" %d", *i.ref->get); + puts(""); } } \ No newline at end of file -- cgit v1.2.3