diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-08-04 23:32:07 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-08-04 23:32:07 +0000 |
commit | ec7f168e2d432f3ef184c86f65e0def1f369f671 (patch) | |
tree | 79c2c720bad5788ba7fc00091e6effb141e6280e /src/parse/parse.c | |
parent | 6b31f0eaae57409c267977a7d658f8900c510dfd (diff) | |
download | libcss-ec7f168e2d432f3ef184c86f65e0def1f369f671.tar.gz libcss-ec7f168e2d432f3ef184c86f65e0def1f369f671.tar.bz2 |
Beginnings of a mechanism to intern known strings and compare pointers effectively.
svn path=/trunk/libcss/; revision=4903
Diffstat (limited to 'src/parse/parse.c')
-rw-r--r-- | src/parse/parse.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/parse/parse.c b/src/parse/parse.c index 533d822..1095c26 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -403,6 +403,31 @@ const char *css_parser_read_charset(css_parser *parser, return parserutils_inputstream_read_charset(parser->stream, source); } +/** + * Add an entry to the parser dictionary + * + * \param parser The parser instance + * \param ptr Pointer to data + * \param len Length, in bytes, of data + * \return Pointer to data in dictionary, or NULL on memory exhaustion + */ +const uint8_t *css_parser_dict_add(css_parser *parser, const uint8_t *ptr, + size_t len) +{ + const parserutils_dict_entry *interned; + parserutils_error perror; + + if (parser == NULL || ptr == NULL || len == 0) + return NULL; + + perror = parserutils_dict_insert(parser->dictionary, ptr, len, + &interned); + if (perror != PARSERUTILS_OK) + return NULL; + + return interned->data; +} + /****************************************************************************** * Helper functions * ******************************************************************************/ |