diff options
author | Anthony J. Bentley <anthony@cathet.us> | 2013-04-26 19:01:52 -0600 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2013-04-27 13:28:47 +0100 |
commit | a4e3ccd6abb97d05121635112bdca44fc0e440b0 (patch) | |
tree | 699ad88c55b44c3e82f2180b6096666919127f19 /test/cscodec-ext8.c | |
parent | a6fd64ee6ca004627cefc7d80e036707bea22bf9 (diff) | |
download | libparserutils-a4e3ccd6abb97d05121635112bdca44fc0e440b0.tar.gz libparserutils-a4e3ccd6abb97d05121635112bdca44fc0e440b0.tar.bz2 |
Don't use the nonportable alloca() during tests.
Diffstat (limited to 'test/cscodec-ext8.c')
-rw-r--r-- | test/cscodec-ext8.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/cscodec-ext8.c b/test/cscodec-ext8.c index bd7dfa4..d47fb2a 100644 --- a/test/cscodec-ext8.c +++ b/test/cscodec-ext8.c @@ -169,7 +169,7 @@ bool handle_line(const char *data, size_t datalen, void *pw) for (end = enc; !isspace(*end); end++) ; - enc_name = alloca(end - enc + 1); + enc_name = malloc(end - enc + 1); memcpy(enc_name, enc, end - enc); enc_name[end - enc] = 0; @@ -178,6 +178,8 @@ bool handle_line(const char *data, size_t datalen, void *pw) PARSERUTILS_OK); ctx->hadenc = true; + + free(enc_name); } } else { if (ctx->indata) { @@ -197,7 +199,7 @@ void run_test(line_ctx *ctx) { static int testnum; size_t destlen = ctx->bufused * 4; - uint8_t *dest = alloca(destlen); + uint8_t *dest = malloc(destlen); uint8_t *pdest = dest; const uint8_t *psrc = ctx->buf; size_t srclen = ctx->bufused; @@ -213,7 +215,7 @@ void run_test(line_ctx *ctx) &pdest, &destlen) == ctx->exp_ret); } else { size_t templen = ctx->bufused * 4; - uint8_t *temp = alloca(templen); + uint8_t *temp = malloc(templen); uint8_t *ptemp = temp; const uint8_t *ptemp2; size_t templen2; @@ -237,6 +239,8 @@ void run_test(line_ctx *ctx) assert(templen2 == 0); assert(temp + (ctx->bufused * 4 - templen) == ptemp2); } + + free(temp); } if (ctx->exp_ret == PARSERUTILS_OK) { assert(srclen == 0); @@ -259,5 +263,7 @@ void run_test(line_ctx *ctx) assert(pdest == dest + ctx->expused); assert(memcmp(dest, ctx->exp, ctx->expused) == 0); + + free(dest); } |