summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-12-14 23:15:34 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2013-12-14 23:15:34 (GMT)
commit528795a5daf767532a42b492db29deeadebcb249 (patch)
tree06b6fba37d2a740341139131cfbd47eb0b59ab7f
parentd509919a3bc507f3898e2166978462badbaab599 (diff)
downloadlibhubbub-528795a5daf767532a42b492db29deeadebcb249.tar.gz
libhubbub-528795a5daf767532a42b492db29deeadebcb249.tar.bz2
Remove client allocation function and update for new lpu API.
-rw-r--r--examples/libxml.c22
-rw-r--r--include/hubbub/functypes.h12
-rw-r--r--include/hubbub/parser.h2
-rw-r--r--src/parser.c28
-rw-r--r--src/tokeniser/tokeniser.c36
-rw-r--r--src/tokeniser/tokeniser.h1
-rw-r--r--src/treebuilder/in_body.c22
-rw-r--r--src/treebuilder/internal.h3
-rw-r--r--src/treebuilder/treebuilder.c41
-rw-r--r--src/treebuilder/treebuilder.h1
-rw-r--r--test/parser.c10
-rw-r--r--test/tokeniser.c12
-rw-r--r--test/tokeniser2.c12
-rw-r--r--test/tokeniser3.c12
-rw-r--r--test/tree-buf.c21
-rw-r--r--test/tree.c10
-rw-r--r--test/tree2.c21
17 files changed, 59 insertions, 207 deletions
diff --git a/examples/libxml.c b/examples/libxml.c
index e970e4c..9530ca3 100644
--- a/examples/libxml.c
+++ b/examples/libxml.c
@@ -127,25 +127,6 @@ static hubbub_tree_handler tree_handler = {
NULL
};
-/**
- * Memory allocation callback.
- *
- * \param ptr Pointer to block to reallocate, or NULL for a new allocation
- * \param len Required length, in bytes. If zero, then free the block
- * \param pw Pointer to our private data
- * \return Pointer to resized block
- */
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- /* In this implementation, we just call realloc.
- * If we have more complex allocation requirements (e.g. multiple
- * allocation arenas, then we could use pw to point to the arena to use)
- */
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
/******************************************************************************
* Main hubbub driver code *
******************************************************************************/
@@ -295,8 +276,7 @@ error_code create_context(const char *charset, context **ctx)
c->document = NULL;
/* Create the parser */
- error = hubbub_parser_create(c->encoding, true, myrealloc, NULL,
- &c->parser);
+ error = hubbub_parser_create(c->encoding, true, &c->parser);
if (error != HUBBUB_OK) {
free(c);
if (error == HUBBUB_BADENCODING)
diff --git a/include/hubbub/functypes.h b/include/hubbub/functypes.h
index 1b65e32..e7cbe6e 100644
--- a/include/hubbub/functypes.h
+++ b/include/hubbub/functypes.h
@@ -20,18 +20,6 @@ extern "C"
#include <hubbub/types.h>
/**
- * Type of allocation function for hubbub
- *
- * The semantics of this function are the same as for realloc().
- *
- * \param ptr Pointer to object to reallocate, or NULL for a new allocation
- * \param size Required length in bytes, or zero to free ::ptr
- * \param pw Pointer to client data
- * \return Pointer to allocated object, or NULL on failure
- */
-typedef void *(*hubbub_allocator_fn)(void *ptr, size_t size, void *pw);
-
-/**
* Type of token handling function
*
* \param token Pointer to token to handle
diff --git a/include/hubbub/parser.h b/include/hubbub/parser.h
index cd5d6b5..bdc5e20 100644
--- a/include/hubbub/parser.h
+++ b/include/hubbub/parser.h
@@ -65,7 +65,7 @@ typedef union hubbub_parser_optparams {
/* Create a hubbub parser */
hubbub_error hubbub_parser_create(const char *enc, bool fix_enc,
- hubbub_allocator_fn alloc, void *pw, hubbub_parser **parser);
+ hubbub_parser **parser);
/* Destroy a hubbub parser */
hubbub_error hubbub_parser_destroy(hubbub_parser *parser);
diff --git a/src/parser.c b/src/parser.c
index 5423922..671e129 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -25,9 +25,6 @@ struct hubbub_parser {
parserutils_inputstream *stream; /**< Input stream instance */
hubbub_tokeniser *tok; /**< Tokeniser instance */
hubbub_treebuilder *tb; /**< Treebuilder instance */
-
- hubbub_allocator_fn alloc; /**< Memory (de)allocation function */
- void *pw; /**< Client data */
};
/**
@@ -35,8 +32,6 @@ struct hubbub_parser {
*
* \param enc Source document encoding, or NULL to autodetect
* \param fix_enc Permit fixing up of encoding if it's frequently misused
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data (may be NULL)
* \param parser Pointer to location to receive parser instance
* \return HUBBUB_OK on success,
* HUBBUB_BADPARM on bad parameters,
@@ -44,16 +39,16 @@ struct hubbub_parser {
* HUBBUB_BADENCODING if ::enc is unsupported
*/
hubbub_error hubbub_parser_create(const char *enc, bool fix_enc,
- hubbub_allocator_fn alloc, void *pw, hubbub_parser **parser)
+ hubbub_parser **parser)
{
parserutils_error perror;
hubbub_error error;
hubbub_parser *p;
- if (alloc == NULL || parser == NULL)
+ if (parser == NULL)
return HUBBUB_BADPARM;
- p = alloc(NULL, sizeof(hubbub_parser), pw);
+ p = malloc(sizeof(hubbub_parser));
if (p == NULL)
return HUBBUB_NOMEM;
@@ -72,30 +67,27 @@ hubbub_error hubbub_parser_create(const char *enc, bool fix_enc,
perror = parserutils_inputstream_create(enc,
enc != NULL ? HUBBUB_CHARSET_CONFIDENT : HUBBUB_CHARSET_UNKNOWN,
- hubbub_charset_extract, alloc, pw, &p->stream);
+ hubbub_charset_extract, &p->stream);
if (perror != PARSERUTILS_OK) {
- alloc(p, 0, pw);
+ free(p);
return hubbub_error_from_parserutils_error(perror);
}
- error = hubbub_tokeniser_create(p->stream, alloc, pw, &p->tok);
+ error = hubbub_tokeniser_create(p->stream, &p->tok);
if (error != HUBBUB_OK) {
parserutils_inputstream_destroy(p->stream);
- alloc(p, 0, pw);
+ free(p);
return error;
}
- error = hubbub_treebuilder_create(p->tok, alloc, pw, &p->tb);
+ error = hubbub_treebuilder_create(p->tok, &p->tb);
if (error != HUBBUB_OK) {
hubbub_tokeniser_destroy(p->tok);
parserutils_inputstream_destroy(p->stream);
- alloc(p, 0, pw);
+ free(p);
return error;
}
- p->alloc = alloc;
- p->pw = pw;
-
*parser = p;
return HUBBUB_OK;
@@ -118,7 +110,7 @@ hubbub_error hubbub_parser_destroy(hubbub_parser *parser)
parserutils_inputstream_destroy(parser->stream);
- parser->alloc(parser, 0, parser->pw);
+ free(parser);
return HUBBUB_OK;
}
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);
diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c
index e736d51..5157e66 100644
--- a/src/treebuilder/in_body.c
+++ b/src/treebuilder/in_body.c
@@ -1162,10 +1162,8 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
/* First up, clone the token's attributes */
if (token->data.tag.n_attributes > 0) {
uint32_t i;
- attrs = treebuilder->alloc(NULL,
- (token->data.tag.n_attributes + 1) *
- sizeof(hubbub_attribute),
- treebuilder->alloc_pw);
+ attrs = malloc((token->data.tag.n_attributes + 1) *
+ sizeof(hubbub_attribute));
if (attrs == NULL)
return HUBBUB_NOMEM;
@@ -1209,7 +1207,7 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = process_form_in_body(treebuilder, &dummy);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
@@ -1221,7 +1219,7 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = process_hr_in_body(treebuilder, &dummy);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
@@ -1233,7 +1231,7 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = process_container_in_body(treebuilder, &dummy);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
@@ -1245,7 +1243,7 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = process_phrasing_in_body(treebuilder, &dummy);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
@@ -1263,7 +1261,7 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = process_character(treebuilder, &dummy);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
@@ -1278,18 +1276,18 @@ hubbub_error process_isindex_in_body(hubbub_treebuilder *treebuilder,
err = reconstruct_active_formatting_list(treebuilder);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
err = insert_element(treebuilder, &dummy.data.tag, false);
if (err != HUBBUB_OK) {
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
return err;
}
/* No longer need attrs */
- treebuilder->alloc(attrs, 0, treebuilder->alloc_pw);
+ free(attrs);
treebuilder->context.frameset_ok = false;
diff --git a/src/treebuilder/internal.h b/src/treebuilder/internal.h
index 503168f..58c21d6 100644
--- a/src/treebuilder/internal.h
+++ b/src/treebuilder/internal.h
@@ -123,9 +123,6 @@ struct hubbub_treebuilder
hubbub_error_handler error_handler; /**< Error handler */
void *error_pw; /**< Error handler data */
-
- hubbub_allocator_fn alloc; /**< Memory (de)allocation function */
- void *alloc_pw; /**< Client private data */
};
hubbub_error hubbub_treebuilder_token_handler(
diff --git a/src/treebuilder/treebuilder.c b/src/treebuilder/treebuilder.c
index 10433b4..a6a4b43 100644
--- a/src/treebuilder/treebuilder.c
+++ b/src/treebuilder/treebuilder.c
@@ -85,25 +85,22 @@ static bool is_form_associated(element_type type);
* Create a hubbub treebuilder
*
* \param tokeniser Underlying tokeniser instance
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \param treebuilder Pointer to location to receive treebuilder instance
* \return HUBBUB_OK on success,
* HUBBUB_BADPARM on bad parameters
* HUBBUB_NOMEM on memory exhaustion
*/
hubbub_error hubbub_treebuilder_create(hubbub_tokeniser *tokeniser,
- hubbub_allocator_fn alloc, void *pw,
hubbub_treebuilder **treebuilder)
{
hubbub_error error;
hubbub_treebuilder *tb;
hubbub_tokeniser_optparams tokparams;
- if (tokeniser == NULL || alloc == NULL || treebuilder == NULL)
+ if (tokeniser == NULL || treebuilder == NULL)
return HUBBUB_BADPARM;
- tb = alloc(NULL, sizeof(hubbub_treebuilder), pw);
+ tb = malloc(sizeof(hubbub_treebuilder));
if (tb == NULL)
return HUBBUB_NOMEM;
@@ -114,11 +111,10 @@ hubbub_error hubbub_treebuilder_create(hubbub_tokeniser *tokeniser,
memset(&tb->context, 0, sizeof(hubbub_treebuilder_context));
tb->context.mode = INITIAL;
- tb->context.element_stack = alloc(NULL,
- ELEMENT_STACK_CHUNK * sizeof(element_context),
- pw);
+ tb->context.element_stack = malloc(
+ ELEMENT_STACK_CHUNK * sizeof(element_context));
if (tb->context.element_stack == NULL) {
- alloc(tb, 0, pw);
+ free(tb);
return HUBBUB_NOMEM;
}
tb->context.stack_alloc = ELEMENT_STACK_CHUNK;
@@ -133,17 +129,14 @@ hubbub_error hubbub_treebuilder_create(hubbub_tokeniser *tokeniser,
tb->error_handler = NULL;
tb->error_pw = NULL;
- tb->alloc = alloc;
- tb->alloc_pw = pw;
-
tokparams.token_handler.handler = hubbub_treebuilder_token_handler;
tokparams.token_handler.pw = tb;
error = hubbub_tokeniser_setopt(tokeniser,
HUBBUB_TOKENISER_TOKEN_HANDLER, &tokparams);
if (error != HUBBUB_OK) {
- alloc(tb->context.element_stack, 0, pw);
- alloc(tb, 0, pw);
+ free(tb->context.element_stack);
+ free(tb);
return error;
}
@@ -206,8 +199,7 @@ hubbub_error hubbub_treebuilder_destroy(hubbub_treebuilder *treebuilder)
treebuilder->context.element_stack[0].node);
}
}
- treebuilder->alloc(treebuilder->context.element_stack, 0,
- treebuilder->alloc_pw);
+ free(treebuilder->context.element_stack);
treebuilder->context.element_stack = NULL;
for (entry = treebuilder->context.formatting_list; entry != NULL;
@@ -220,10 +212,10 @@ hubbub_error hubbub_treebuilder_destroy(hubbub_treebuilder *treebuilder)
entry->details.node);
}
- treebuilder->alloc(entry, 0, treebuilder->alloc_pw);
+ free(entry);
}
- treebuilder->alloc(treebuilder, 0, treebuilder->alloc_pw);
+ free(treebuilder);
return HUBBUB_OK;
}
@@ -1086,12 +1078,11 @@ hubbub_error element_stack_push(hubbub_treebuilder *treebuilder,
uint32_t slot = treebuilder->context.current_node + 1;
if (slot >= treebuilder->context.stack_alloc) {
- element_context *temp = treebuilder->alloc(
+ element_context *temp = realloc(
treebuilder->context.element_stack,
(treebuilder->context.stack_alloc +
ELEMENT_STACK_CHUNK) *
- sizeof(element_context),
- treebuilder->alloc_pw);
+ sizeof(element_context));
if (temp == NULL)
return HUBBUB_NOMEM;
@@ -1303,8 +1294,7 @@ hubbub_error formatting_list_append(hubbub_treebuilder *treebuilder,
{
formatting_list_entry *entry;
- entry = treebuilder->alloc(NULL, sizeof(formatting_list_entry),
- treebuilder->alloc_pw);
+ entry = malloc(sizeof(formatting_list_entry));
if (entry == NULL)
return HUBBUB_NOMEM;
@@ -1353,8 +1343,7 @@ hubbub_error formatting_list_insert(hubbub_treebuilder *treebuilder,
assert(next->prev == prev);
}
- entry = treebuilder->alloc(NULL, sizeof(formatting_list_entry),
- treebuilder->alloc_pw);
+ entry = malloc(sizeof(formatting_list_entry));
if (entry == NULL)
return HUBBUB_NOMEM;
@@ -1411,7 +1400,7 @@ hubbub_error formatting_list_remove(hubbub_treebuilder *treebuilder,
else
entry->next->prev = entry->prev;
- treebuilder->alloc(entry, 0, treebuilder->alloc_pw);
+ free(entry);
return HUBBUB_OK;
}
diff --git a/src/treebuilder/treebuilder.h b/src/treebuilder/treebuilder.h
index 2ff1c38..5308eba 100644
--- a/src/treebuilder/treebuilder.h
+++ b/src/treebuilder/treebuilder.h
@@ -48,7 +48,6 @@ typedef union hubbub_treebuilder_optparams {
/* Create a hubbub treebuilder */
hubbub_error hubbub_treebuilder_create(hubbub_tokeniser *tokeniser,
- hubbub_allocator_fn alloc, void *pw,
hubbub_treebuilder **treebuilder);
/* Destroy a hubbub treebuilder */
diff --git a/test/parser.c b/test/parser.c
index 93bdad2..6b0db45 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -12,13 +12,6 @@
static hubbub_error token_handler(const hubbub_token *token, void *pw);
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
{
hubbub_parser *parser;
@@ -31,8 +24,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
UNUSED(argc);
- assert(hubbub_parser_create("UTF-8", false, myrealloc, NULL, &parser) ==
- HUBBUB_OK);
+ assert(hubbub_parser_create("UTF-8", false, &parser) == HUBBUB_OK);
params.token_handler.handler = token_handler;
params.token_handler.pw = NULL;
diff --git a/test/tokeniser.c b/test/tokeniser.c
index 717e34e..1cac0af 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -13,13 +13,6 @@
static hubbub_error token_handler(const hubbub_token *token, void *pw);
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
int main(int argc, char **argv)
{
parserutils_inputstream *stream;
@@ -36,10 +29,9 @@ int main(int argc, char **argv)
}
assert(parserutils_inputstream_create("UTF-8", 0, NULL,
- myrealloc, NULL, &stream) == PARSERUTILS_OK);
+ &stream) == PARSERUTILS_OK);
- assert(hubbub_tokeniser_create(stream, myrealloc, NULL, &tok) ==
- HUBBUB_OK);
+ assert(hubbub_tokeniser_create(stream, &tok) == HUBBUB_OK);
params.token_handler.handler = token_handler;
params.token_handler.pw = NULL;
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index 443b71d..c8ab9c0 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -32,13 +32,6 @@ typedef struct context {
static void run_test(context *ctx);
static hubbub_error token_handler(const hubbub_token *token, void *pw);
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
int main(int argc, char **argv)
{
struct json_object *json;
@@ -135,10 +128,9 @@ void run_test(context *ctx)
ctx->char_off = 0;
assert(parserutils_inputstream_create("UTF-8", 0, NULL,
- myrealloc, NULL, &stream) == PARSERUTILS_OK);
+ &stream) == PARSERUTILS_OK);
- assert(hubbub_tokeniser_create(stream, myrealloc, NULL, &tok) ==
- HUBBUB_OK);
+ assert(hubbub_tokeniser_create(stream, &tok) == HUBBUB_OK);
if (ctx->last_start_tag != NULL) {
/* Fake up a start tag, in PCDATA state */
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index 9f0f84e..949ddd0 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -30,13 +30,6 @@ typedef struct context {
static void run_test(context *ctx);
static hubbub_error token_handler(const hubbub_token *token, void *pw);
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
int main(int argc, char **argv)
{
struct json_object *json;
@@ -133,10 +126,9 @@ void run_test(context *ctx)
ctx->char_off = 0;
assert(parserutils_inputstream_create("UTF-8", 0, NULL,
- myrealloc, NULL, &stream) == PARSERUTILS_OK);
+ &stream) == PARSERUTILS_OK);
- assert(hubbub_tokeniser_create(stream, myrealloc, NULL, &tok) ==
- HUBBUB_OK);
+ assert(hubbub_tokeniser_create(stream, &tok) == HUBBUB_OK);
if (ctx->last_start_tag != NULL) {
/* Fake up a start tag, in PCDATA state */
diff --git a/test/tree-buf.c b/test/tree-buf.c
index 9814932..83447a2 100644
--- a/test/tree-buf.c
+++ b/test/tree-buf.c
@@ -120,24 +120,6 @@ static hubbub_tree_handler tree_handler = {
NULL
};
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- void *ret;
-
- UNUSED(pw);
-
- /* A half-arsed attempt at filling freshly allocated space with junk. */
- if (ptr == NULL) {
- ret = malloc(len);
- if (ret != NULL)
- memset(ret, 0xdf, len);
- } else {
- ret = realloc(ptr, len);
- }
-
- return ret;
-}
-
/*
* Create, initialise, and return, a parser instance.
@@ -147,8 +129,7 @@ static hubbub_parser *setup_parser(void)
hubbub_parser *parser;
hubbub_parser_optparams params;
- assert(hubbub_parser_create("UTF-8", false, myrealloc, NULL, &parser) ==
- HUBBUB_OK);
+ assert(hubbub_parser_create("UTF-8", false, &parser) == HUBBUB_OK);
params.tree_handler = &tree_handler;
assert(hubbub_parser_setopt(parser, HUBBUB_PARSER_TREE_HANDLER,
diff --git a/test/tree.c b/test/tree.c
index 9896df8..14b76a3 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -78,13 +78,6 @@ static hubbub_tree_handler tree_handler = {
NULL
};
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
{
hubbub_parser *parser;
@@ -106,8 +99,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
}
node_ref_alloc = NODE_REF_CHUNK;
- assert(hubbub_parser_create("UTF-8", false, myrealloc, NULL, &parser) ==
- HUBBUB_OK);
+ assert(hubbub_parser_create("UTF-8", false, &parser) == HUBBUB_OK);
params.tree_handler = &tree_handler;
assert(hubbub_parser_setopt(parser, HUBBUB_PARSER_TREE_HANDLER,
diff --git a/test/tree2.c b/test/tree2.c
index 15f75db..d5d4c72 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -120,24 +120,6 @@ static hubbub_tree_handler tree_handler = {
NULL
};
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- void *ret;
-
- UNUSED(pw);
-
- /* A half-arsed attempt at filling freshly allocated space with junk. */
- if (ptr == NULL) {
- ret = malloc(len);
- if (ret != NULL)
- memset(ret, 0xdf, len);
- } else {
- ret = realloc(ptr, len);
- }
-
- return ret;
-}
-
/*
* Create, initialise, and return, a parser instance.
@@ -147,8 +129,7 @@ static hubbub_parser *setup_parser(void)
hubbub_parser *parser;
hubbub_parser_optparams params;
- assert(hubbub_parser_create("UTF-8", false, myrealloc, NULL, &parser) ==
- HUBBUB_OK);
+ assert(hubbub_parser_create("UTF-8", false, &parser) == HUBBUB_OK);
params.tree_handler = &tree_handler;
assert(hubbub_parser_setopt(parser, HUBBUB_PARSER_TREE_HANDLER,