Provides a cache for regular expressions. Applications first allocate
a cache with gnome_regex_cache_new() and access the regular
expressions through the gnome_regex_cache_compile() function (this
will fetch the compiled value from the cache or re-compile it if
required).
Details
struct GnomeRegexCache
typedef struct {
int size; /* Total number of cache slots. */
int next; /* Next available slot. */
char **regexs; /* Regular expression strings. */
regex_t *patterns; /* Compiled expressions. */
/* FIXME: probably should cache compilation flags along with
regex and use those to determine caching. For now we
assume that the flags never change. Another option would
be to put the flag info into this structure and just not
let the user ever change it. */
} GnomeRegexCache;
void gnome_regex_cache_set_size (GnomeRegexCache *rxc,
int new_size);
Sets the maxiumum number of regular expressions the cache can
hold. If this is less than the number of currently cached
expressions, then the oldest expressions are deleted.
rxc :
A regular expression cache object
new_size :
new size of cache
gnome_regex_cache_compile ()
regex_t* gnome_regex_cache_compile (GnomeRegexCache *rxc,
const char *pattern,
int flags);
This compiles a regular expression. If the expression is cached,
the previously computed value is returned. Otherwise, the
expression is compiled, cached, and then returned.