From 65e7df44d3d98cade6ab1ab4d0c3fa1ecb07c9d5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 3 Apr 2020 14:22:44 +0900 Subject: [PATCH] [qfcc] Add function to see if a string is in a pool Makes for a nice string set. --- tools/qfcc/include/strpool.h | 1 + tools/qfcc/source/strpool.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/tools/qfcc/include/strpool.h b/tools/qfcc/include/strpool.h index 6cdc8eb83..fbb4bc049 100644 --- a/tools/qfcc/include/strpool.h +++ b/tools/qfcc/include/strpool.h @@ -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. diff --git a/tools/qfcc/source/strpool.c b/tools/qfcc/source/strpool.c index 0f10f81ee..d3ab07a1c 100644 --- a/tools/qfcc/source/strpool.c +++ b/tools/qfcc/source/strpool.c @@ -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) {