47 static GHashTable* qof_string_cache = NULL;
50 qof_get_string_cache(
void)
52 if (!qof_string_cache)
54 qof_string_cache = g_hash_table_new_full(
60 return qof_string_cache;
66 (void)qof_get_string_cache();
74 g_hash_table_destroy(qof_string_cache);
76 qof_string_cache = NULL;
84 if (key && key[0] != 0)
86 GHashTable* cache = qof_get_string_cache();
89 if (g_hash_table_lookup_extended(cache, key, &cache_key, &value))
91 guint* refcount = (guint*)value;
94 g_hash_table_remove(cache, key);
116 GHashTable* cache = qof_get_string_cache();
119 if (g_hash_table_lookup_extended(cache, key, &cache_key, &value))
121 guint* refcount = (guint*)value;
123 return static_cast <
char *> (cache_key);
127 gpointer new_key = g_strdup(static_cast<const char*>(key));
128 guint* refcount =
static_cast<unsigned int*
>(g_malloc(
sizeof(guint)));
130 g_hash_table_insert(cache, new_key, refcount);
131 return static_cast <
char *> (new_key);
const char * qof_string_cache_replace(char const *dst, char const *src)
Same as CACHE_REPLACE below, but safe to call from C++.
void qof_string_cache_destroy(void)
Destroy the qof_string_cache.
const char * qof_string_cache_insert(const char *key)
You can use this function with g_hash_table_insert(), for the key (or value), as long as you use the ...
void qof_string_cache_remove(const char *key)
You can use this function as a destroy notifier for a GHashTable that uses common strings as keys (or...
void qof_string_cache_init(void)
The QOF String Cache: