diff options
-rw-r--r-- | src/lex/lex.c | 3 | ||||
-rw-r--r-- | src/parse/language.c | 2 | ||||
-rw-r--r-- | src/parse/parse.c | 10 | ||||
-rw-r--r-- | src/parse/properties/utils.c | 2 | ||||
-rw-r--r-- | src/utils/utils.c | 16 | ||||
-rw-r--r-- | src/utils/utils.h | 5 | ||||
-rw-r--r-- | test/lex-auto.c | 10 | ||||
-rw-r--r-- | test/lex.c | 11 |
8 files changed, 9 insertions, 50 deletions
diff --git a/src/lex/lex.c b/src/lex/lex.c index 2ab21d1..0f956db 100644 --- a/src/lex/lex.c +++ b/src/lex/lex.c @@ -1707,8 +1707,7 @@ css_error consumeEscape(css_lexer *lexer, bool nl) /* Create unescaped buffer, if it doesn't already exist */ if (lexer->unescapedTokenData == NULL) { - perror = parserutils_buffer_create(css_alloc, CSS_ALLOC_PW, - &lexer->unescapedTokenData); + perror = parserutils_buffer_create(&lexer->unescapedTokenData); if (perror != PARSERUTILS_OK) return css_error_from_parserutils_error(perror); } diff --git a/src/parse/language.c b/src/parse/language.c index 5dac773..11e2b2f 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -129,7 +129,7 @@ css_error css__language_create(css_stylesheet *sheet, css_parser *parser, return CSS_NOMEM; perror = parserutils_stack_create(sizeof(context_entry), - STACK_CHUNK, css_alloc, CSS_ALLOC_PW, &c->context); + STACK_CHUNK, &c->context); if (perror != PARSERUTILS_OK) { free(c); return css_error_from_parserutils_error(perror); diff --git a/src/parse/parse.c b/src/parse/parse.c index b52e9f1..b65b0f5 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -402,8 +402,7 @@ css_error css__parser_create_internal(const char *charset, return CSS_NOMEM; perror = parserutils_inputstream_create(charset, cs_source, - css__charset_extract, css_alloc, CSS_ALLOC_PW, - &p->stream); + css__charset_extract, &p->stream); if (perror != PARSERUTILS_OK) { free(p); return css_error_from_parserutils_error(perror); @@ -417,8 +416,7 @@ css_error css__parser_create_internal(const char *charset, } perror = parserutils_stack_create(sizeof(parser_state), - STACK_CHUNK, css_alloc, CSS_ALLOC_PW, - &p->states); + STACK_CHUNK, &p->states); if (perror != PARSERUTILS_OK) { css__lexer_destroy(p->lexer); parserutils_inputstream_destroy(p->stream); @@ -427,7 +425,7 @@ css_error css__parser_create_internal(const char *charset, } perror = parserutils_vector_create(sizeof(css_token), - STACK_CHUNK, css_alloc, CSS_ALLOC_PW, &p->tokens); + STACK_CHUNK, &p->tokens); if (perror != PARSERUTILS_OK) { parserutils_stack_destroy(p->states); css__lexer_destroy(p->lexer); @@ -437,7 +435,7 @@ css_error css__parser_create_internal(const char *charset, } perror = parserutils_stack_create(sizeof(char), - STACK_CHUNK, css_alloc, CSS_ALLOC_PW, &p->open_items); + STACK_CHUNK, &p->open_items); if (perror != PARSERUTILS_OK) { parserutils_vector_destroy(p->tokens); parserutils_stack_destroy(p->states); diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 4e43c8c..bfcba04 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -1118,7 +1118,7 @@ css_error css__ident_list_to_string(css_language *c, lwc_string *interned; lwc_error lerror; - perror = parserutils_buffer_create(css_alloc, CSS_ALLOC_PW, &buffer); + perror = parserutils_buffer_create(&buffer); if (perror != PARSERUTILS_OK) return css_error_from_parserutils_error(perror); diff --git a/src/utils/utils.c b/src/utils/utils.c index 1899b23..1745ea0 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -130,19 +130,3 @@ css_fixed css__number_from_string(const uint8_t *data, size_t len, return (intpart << 10) | fracpart; } - -/* Allocator to pass to libparserutils */ -void *css_alloc(void *data, size_t len, void *pw) -{ - UNUSED(pw); - - if (data == NULL) { - return (len > 0) ? malloc(len) : NULL; - } - if (len == 0) { - free(data); - return NULL; - } - return realloc(data, len); -} - diff --git a/src/utils/utils.h b/src/utils/utils.h index 3f7fcd0..c1f8d80 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -77,9 +77,4 @@ static inline css_error css_error_from_lwc_error(lwc_error err) return CSS_INVALID; } - -/* Allocator to pass to libparserutils */ -#define CSS_ALLOC_PW NULL -void *css_alloc(void *data, size_t len, void *pw); - #endif diff --git a/test/lex-auto.c b/test/lex-auto.c index 6b22f6f..f2f6007 100644 --- a/test/lex-auto.c +++ b/test/lex-auto.c @@ -42,13 +42,6 @@ static css_token_type string_to_type(const char *data, size_t len); static void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen); -static void *myrealloc(void *data, size_t len, void *pw) -{ - UNUSED(pw); - - return realloc(data, len); -} - int main(int argc, char **argv) { line_ctx ctx; @@ -274,8 +267,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) static int testnum; assert(parserutils_inputstream_create("UTF-8", CSS_CHARSET_DICTATED, - css__charset_extract, myrealloc, NULL, &input) == - PARSERUTILS_OK); + css__charset_extract, &input) == PARSERUTILS_OK); assert(css__lexer_create(input, &lexer) == CSS_OK); @@ -16,14 +16,6 @@ #define ITERATIONS (1) #define DUMP_TOKENS (0) - -static void *myrealloc(void *data, size_t len, void *pw) -{ - UNUSED(pw); - - return realloc(data, len); -} - static void printToken(const css_token *token) { #if !DUMP_TOKENS @@ -138,8 +130,7 @@ int main(int argc, char **argv) for (i = 0; i < ITERATIONS; i++) { assert(parserutils_inputstream_create("UTF-8", CSS_CHARSET_DICTATED,css__charset_extract, - (parserutils_alloc) myrealloc, NULL, &stream) == - PARSERUTILS_OK); + &stream) == PARSERUTILS_OK); assert(css__lexer_create(stream, &lexer) == CSS_OK); |