diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-12-14 23:15:34 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-12-14 23:15:34 +0000 |
commit | 528795a5daf767532a42b492db29deeadebcb249 (patch) | |
tree | 06b6fba37d2a740341139131cfbd47eb0b59ab7f /src/tokeniser | |
parent | d509919a3bc507f3898e2166978462badbaab599 (diff) | |
download | libhubbub-528795a5daf767532a42b492db29deeadebcb249.tar.gz libhubbub-528795a5daf767532a42b492db29deeadebcb249.tar.bz2 |
Remove client allocation function and update for new lpu API.
Diffstat (limited to 'src/tokeniser')
-rw-r--r-- | src/tokeniser/tokeniser.c | 36 | ||||
-rw-r--r-- | src/tokeniser/tokeniser.h | 1 |
2 files changed, 12 insertions, 25 deletions
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c index 2fff50d..a7e67a1 100644 --- a/src/tokeniser/tokeniser.c +++ b/src/tokeniser/tokeniser.c @@ -181,9 +181,6 @@ struct hubbub_tokeniser { hubbub_error_handler error_handler; /**< Error handling callback */ void *error_pw; /**< Error handler data */ - - hubbub_allocator_fn alloc; /**< Memory (de)allocation function */ - void *alloc_pw; /**< Client private data */ }; static hubbub_error hubbub_tokeniser_handle_data(hubbub_tokeniser *tokeniser); @@ -280,37 +277,34 @@ static hubbub_error hubbub_tokeniser_emit_token(hubbub_tokeniser *tokeniser, * Create a hubbub tokeniser * * \param input Input stream instance - * \param alloc Memory (de)allocation function - * \param pw Pointer to client-specific private data (may be NULL) * \param tokeniser Pointer to location to receive tokeniser instance * \return HUBBUB_OK on success, * HUBBUB_BADPARM on bad parameters, * HUBBUB_NOMEM on memory exhaustion */ hubbub_error hubbub_tokeniser_create(parserutils_inputstream *input, - hubbub_allocator_fn alloc, void *pw, hubbub_tokeniser **tokeniser) { parserutils_error perror; hubbub_tokeniser *tok; - if (input == NULL || alloc == NULL || tokeniser == NULL) + if (input == NULL || tokeniser == NULL) return HUBBUB_BADPARM; - tok = alloc(NULL, sizeof(hubbub_tokeniser), pw); + tok = malloc(sizeof(hubbub_tokeniser)); if (tok == NULL) return HUBBUB_NOMEM; - perror = parserutils_buffer_create(alloc, pw, &tok->buffer); + perror = parserutils_buffer_create(&tok->buffer); if (perror != PARSERUTILS_OK) { - alloc(tok, 0, pw); + free(tok); return hubbub_error_from_parserutils_error(perror); } - perror = parserutils_buffer_create(alloc, pw, &tok->insert_buf); + perror = parserutils_buffer_create(&tok->insert_buf); if (perror != PARSERUTILS_OK) { parserutils_buffer_destroy(tok->buffer); - alloc(tok, 0, pw); + free(tok); return hubbub_error_from_parserutils_error(perror); } @@ -330,9 +324,6 @@ hubbub_error hubbub_tokeniser_create(parserutils_inputstream *input, tok->error_handler = NULL; tok->error_pw = NULL; - tok->alloc = alloc; - tok->alloc_pw = pw; - memset(&tok->context, 0, sizeof(hubbub_tokeniser_context)); *tokeniser = tok; @@ -352,15 +343,14 @@ hubbub_error hubbub_tokeniser_destroy(hubbub_tokeniser *tokeniser) return HUBBUB_BADPARM; if (tokeniser->context.current_tag.attributes != NULL) { - tokeniser->alloc(tokeniser->context.current_tag.attributes, - 0, tokeniser->alloc_pw); + free(tokeniser->context.current_tag.attributes); } parserutils_buffer_destroy(tokeniser->insert_buf); parserutils_buffer_destroy(tokeniser->buffer); - tokeniser->alloc(tokeniser, 0, tokeniser->alloc_pw); + free(tokeniser); return HUBBUB_OK; } @@ -1202,10 +1192,9 @@ hubbub_error hubbub_tokeniser_handle_before_attribute_name( /** \todo parse error */ } - attr = tokeniser->alloc(ctag->attributes, + attr = realloc(ctag->attributes, (ctag->n_attributes + 1) * - sizeof(hubbub_attribute), - tokeniser->alloc_pw); + sizeof(hubbub_attribute)); if (attr == NULL) return HUBBUB_NOMEM; @@ -1334,10 +1323,9 @@ hubbub_error hubbub_tokeniser_handle_after_attribute_name( /** \todo parse error */ } - attr = tokeniser->alloc(ctag->attributes, + attr = realloc(ctag->attributes, (ctag->n_attributes + 1) * - sizeof(hubbub_attribute), - tokeniser->alloc_pw); + sizeof(hubbub_attribute)); if (attr == NULL) return HUBBUB_NOMEM; diff --git a/src/tokeniser/tokeniser.h b/src/tokeniser/tokeniser.h index ed46d60..5700923 100644 --- a/src/tokeniser/tokeniser.h +++ b/src/tokeniser/tokeniser.h @@ -55,7 +55,6 @@ typedef union hubbub_tokeniser_optparams { /* Create a hubbub tokeniser */ hubbub_error hubbub_tokeniser_create(parserutils_inputstream *input, - hubbub_allocator_fn alloc, void *pw, hubbub_tokeniser **tokeniser); /* Destroy a hubbub tokeniser */ hubbub_error hubbub_tokeniser_destroy(hubbub_tokeniser *tokeniser); |