[qfcc] Add function to see if a string is in a pool

Makes for a nice string set.
This commit is contained in:
Bill Currie 2020-04-03 14:22:44 +09:00
parent 9089744290
commit 65e7df44d3
2 changed files with 9 additions and 0 deletions

View file

@ -42,6 +42,7 @@ strpool_t *strpool_new (void);
strpool_t *strpool_build (const char *strings, int size);
void strpool_delete (strpool_t *strpool);
int strpool_addstr (strpool_t *strpool, const char *str);
int strpool_findstr (strpool_t *strpool, const char *str);
/** Smart strdup.

View file

@ -121,6 +121,14 @@ strpool_addstr (strpool_t *strpool, const char *str)
return s;
}
int
strpool_findstr (strpool_t *strpool, const char *str)
{
if (!str)
return 0;
return (intptr_t) Hash_Find (strpool->str_tab, str);
}
static const char *
ss_get_key (const void *s, void *unused)
{