Index: tests/uniq_name/tester.c =================================================================== --- tests/uniq_name/tester.c (revision 2676) +++ tests/uniq_name/tester.c (revision 2677) @@ -8,27 +8,27 @@ /* Initialize the group with defaults */ unm_init(&group1); - printf("'%s'\n", unm_name(&group1, "foo")); - printf("'%s'\n", unm_name(&group1, "bar")); - printf("'%s'\n", unm_name(&group1, "bar")); - printf("'%s'\n", unm_name(&group1, "baz")); + printf("'%s'\n", unm_name(&group1, "foo", (void *)0x01)); + printf("'%s'\n", unm_name(&group1, "bar", (void *)0x42)); + printf("'%s'\n", unm_name(&group1, "bar", (void *)0x66)); + printf("'%s'\n", unm_name(&group1, "baz", NULL)); /* test forced collision */ - printf("'%s'\n", unm_name(&group1, "forced")); - printf("'%s'\n", unm_name(&group1, "forced_dup1")); - printf("'%s'\n", unm_name(&group1, "forced_dup2")); - printf("'%s'\n", unm_name(&group1, "forced")); /* this would end up as forced_dup3 */ - printf("'%s'\n", unm_name(&group1, "forced")); /* ... _dup4 */ + printf("'%s'\n", unm_name(&group1, "forced", NULL)); + printf("'%s'\n", unm_name(&group1, "forced_dup1", NULL)); + printf("'%s'\n", unm_name(&group1, "forced_dup2", NULL)); + printf("'%s'\n", unm_name(&group1, "forced", NULL)); /* this would end up as forced_dup3 */ + printf("'%s'\n", unm_name(&group1, "forced", NULL)); /* ... _dup4 */ /* test global dup ctr */ - printf("'%s'\n", unm_name(&group1, "foo")); /* ... _dup5 */ + printf("'%s'\n", unm_name(&group1, "foo", NULL)); /* ... _dup5 */ /* unknown name gets named */ - printf("'%s'\n", unm_name(&group1, NULL)); /* this is the first unnamed item, so it won't get a suffix */ - printf("'%s'\n", unm_name(&group1, NULL)); /* gets suffixed because of the collision */ + printf("'%s'\n", unm_name(&group1, NULL, NULL)); /* this is the first unnamed item, so it won't get a suffix */ + printf("'%s'\n", unm_name(&group1, NULL, NULL)); /* gets suffixed because of the collision */ /* empty name is like unknown name too */ - printf("'%s'\n", unm_name(&group1, "")); + printf("'%s'\n", unm_name(&group1, "", NULL)); /* Optional: change configuration, even on the fly: */ @@ -41,10 +41,18 @@ group1.ctr = 0; /* Adding three more unnamed items will demonstrate how the new config settings take effect */ - printf("'%s'\n", unm_name(&group1, NULL)); - printf("'%s'\n", unm_name(&group1, NULL)); - printf("'%s'\n", unm_name(&group1, NULL)); + printf("'%s'\n", unm_name(&group1, NULL, NULL)); + printf("'%s'\n", unm_name(&group1, NULL, NULL)); + printf("'%s'\n", unm_name(&group1, NULL, NULL)); + /* Optional: iterate over all items once more, e.g. to generate an index + Warning: order is not guaranteed. */ + { + htsp_entry_t *e; + for (e = htsp_first(&group1.seen); e; e = htsp_next(&group1.seen, e)) + printf("name='%s' user_data='%p'\n", e->key, e->value); + } + /* Release all memory */ unm_uninit(&group1); } Index: tests/uniq_name/tester.ref =================================================================== --- tests/uniq_name/tester.ref (revision 2676) +++ tests/uniq_name/tester.ref (revision 2677) @@ -14,3 +14,19 @@ 'anonymous' 'anonymous::0' 'anonymous::1' +name='forced_dup1' user_data='(nil)' +name='forced_dup2' user_data='(nil)' +name='forced_dup3' user_data='(nil)' +name='forced_dup4' user_data='(nil)' +name='foo' user_data='0x1' +name='baz' user_data='(nil)' +name='bar_dup0' user_data='0x66' +name='unnamed_dup6' user_data='(nil)' +name='forced' user_data='(nil)' +name='unnamed_dup7' user_data='(nil)' +name='unnamed' user_data='(nil)' +name='anonymous' user_data='(nil)' +name='anonymous::0' user_data='(nil)' +name='anonymous::1' user_data='(nil)' +name='bar' user_data='0x42' +name='foo_dup5' user_data='(nil)'