Add functions to create and free string cache(s)

This commit is contained in:
Panu Matilainen 2008-11-20 10:15:08 +02:00
parent 325198377d
commit 5487213d18
2 changed files with 20 additions and 1 deletions

View File

@ -26,7 +26,6 @@
* the dumb linear lookup appears to be fast enough and hash table seems
* like an overkill.
*/
typedef struct strcache_s *strcache;
struct strcache_s {
char **uniq;
scidx_t num;
@ -69,6 +68,25 @@ static const char *strcacheGet(strcache cache, scidx_t idx)
return name;
}
static strcache strcacheNew(void)
{
strcache cache = xcalloc(1, sizeof(*cache));
return cache;
}
static strcache strcacheFree(strcache cache)
{
if (cache != NULL) {
for (scidx_t i = 0; i < cache->num; i++) {
free(cache->uniq[i]);
}
cache->uniq = _free(cache->uniq);
free(cache);
}
return NULL;
}
int _rpmfi_debug = 0;
rpmfi rpmfiUnlink(rpmfi fi, const char * msg)

View File

@ -23,6 +23,7 @@ struct sharedFileInfo_s {
* 65535, should be plenty but easy to bump if ever needed.
*/
typedef uint16_t scidx_t;
typedef struct strcache_s *strcache;
/**
* A package filename set.