diff options
Diffstat (limited to 'src/tokeniser/tokeniser.c')
-rw-r--r-- | src/tokeniser/tokeniser.c | 36 |
1 files changed, 12 insertions, 24 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; |