4 * Copyright (c) Tuomo Valkonen 2004.
6 * You may distribute and modify this library under the terms of either
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
15 #include "stringstore.h"
18 static Rb_node stringstore=NULL;
21 const char *stringstore_get(StringId id)
23 return (const char*)(((Rb_node)id)->k.key);
27 StringId stringstore_find(const char *str)
35 node=rb_find_key_n(stringstore, str, &found);
40 return (StringId)node;
44 StringId stringstore_alloc(const char *str)
46 Rb_node node=(Rb_node)stringstore_find(str);
54 if(stringstore==NULL){
55 stringstore=make_rb();
65 node=rb_insert(stringstore, s, NULL);
72 return (StringId)node;
76 void stringstore_free(StringId id)
78 Rb_node node=(Rb_node)id;
81 warn("Attempt to free un-allocated string from stringstore.");
86 warn("Stringstore reference count corrupted.");
93 char *s=(char*)(node->k.key);