summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-09-23 09:48:32 +0200
committerTyge Løvset <[email protected]>2021-09-23 09:48:32 +0200
commit4ab5b3f6f5c841ab8c2202e838979a0d6df91530 (patch)
treef194fbbbada051072ae3da28aee15caaaf4be2d6
parent9058dd37ee3eda1dc004e07218cd8115e3fa4f09 (diff)
downloadSTC-modified-4ab5b3f6f5c841ab8c2202e838979a0d6df91530.tar.gz
STC-modified-4ab5b3f6f5c841ab8c2202e838979a0d6df91530.zip
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).
-rw-r--r--examples/new_sptr.c17
1 files 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 <stc/csptr.h>
#define i_tag iptr
-#define i_key csptr_int
-#define i_cmp csptr_int_compare
+#define i_key_csptr int
#include <stc/csset.h>
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