summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony J. Bentley <anthony@cathet.us>2013-04-27 00:58:59 (GMT)
committer Vincent Sanders <vince@netsurf-browser.org>2013-04-27 07:42:47 (GMT)
commitff31fd617c976832422206a9d36ecd395f45cbaf (patch)
treeaea444f52ce76aa4133cf93f48e241a4b5fbecf0
parentfdf0e1a4dfc42fe0e661bb85eb813e8b187e80c9 (diff)
downloadlibhubbub-ff31fd617c976832422206a9d36ecd395f45cbaf.tar.gz
libhubbub-ff31fd617c976832422206a9d36ecd395f45cbaf.tar.bz2
Don't use the nonportable alloca() during tests.
-rw-r--r--test/parser.c4
-rw-r--r--test/tokeniser2.c4
-rw-r--r--test/tokeniser3.c4
-rw-r--r--test/tree.c4
4 files changed, 12 insertions, 4 deletions
diff --git a/test/parser.c b/test/parser.c
index 41dd41b..0670ebf 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -25,7 +25,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser_optparams params;
FILE *fp;
size_t len, origlen;
- uint8_t *buf = alloca(CHUNK_SIZE);
+ uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
@@ -65,6 +65,8 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
fclose(fp);
+ free(buf);
+
charset = hubbub_parser_read_charset(parser, &cssource);
printf("Charset: %s (from %d)\n", charset, cssource);
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index cf0311d..780c646 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -143,7 +143,7 @@ void run_test(context *ctx)
if (ctx->last_start_tag != NULL) {
/* Fake up a start tag, in PCDATA state */
size_t len = strlen(ctx->last_start_tag) + 3;
- uint8_t *buf = alloca(len);
+ uint8_t *buf = malloc(len);
snprintf((char *) buf, len, "<%s>",
ctx->last_start_tag);
@@ -152,6 +152,8 @@ void run_test(context *ctx)
buf, len - 1) == HUBBUB_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
+
+ free(buf);
}
if (ctx->process_cdata) {
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index 58a1f34..c74c9aa 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -141,7 +141,7 @@ void run_test(context *ctx)
if (ctx->last_start_tag != NULL) {
/* Fake up a start tag, in PCDATA state */
size_t len = strlen(ctx->last_start_tag) + 3;
- uint8_t *buf = alloca(len);
+ uint8_t *buf = malloc(len);
snprintf((char *) buf, len, "<%s>",
ctx->last_start_tag);
@@ -150,6 +150,8 @@ void run_test(context *ctx)
buf, len - 1) == HUBBUB_OK);
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
+
+ free(buf);
}
if (ctx->process_cdata) {
diff --git a/test/tree.c b/test/tree.c
index 85fd21a..d8319e6 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -91,7 +91,7 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser_optparams params;
FILE *fp;
size_t len, origlen;
- uint8_t *buf = alloca(CHUNK_SIZE);
+ uint8_t *buf = malloc(CHUNK_SIZE);
const char *charset;
hubbub_charset_source cssource;
bool passed = true;
@@ -144,6 +144,8 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
fclose(fp);
+ free(buf);
+
charset = hubbub_parser_read_charset(parser, &cssource);
printf("Charset: %s (from %d)\n", charset, cssource);