summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-01-23 14:59:59 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-01-23 14:59:59 -0500
commitf249c357572b146a5ad30221f525834efc667a33 (patch)
tree2f2451ee424dcc7d306ce5c49e84a8de124efedd
parent54eac9ca9c3e3979003d95a58ffb7f1289877b2b (diff)
Fix issues with empty page buffers for tasks
-rw-r--r--src/c/urweb.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 2af21b7a..ce8a8b1b 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -462,8 +462,10 @@ uw_context uw_init(void *logger_data, uw_logger log_debug) {
ctx->get_header = NULL;
ctx->get_header_data = NULL;
- uw_buffer_init(uw_headers_max, &ctx->outHeaders, 0);
- uw_buffer_init(uw_page_max, &ctx->page, 0);
+ uw_buffer_init(uw_headers_max, &ctx->outHeaders, 1);
+ ctx->outHeaders.start[0] = 0;
+ uw_buffer_init(uw_page_max, &ctx->page, 1);
+ ctx->page.start[0] = 0;
ctx->returning_indirectly = 0;
uw_buffer_init(uw_heap_max, &ctx->heap, uw_min_heap);
uw_buffer_init(uw_script_max, &ctx->script, 1);
@@ -1498,10 +1500,11 @@ static void uw_check(uw_context ctx, size_t extra) {
static void uw_writec_unsafe(uw_context ctx, char c) {
*(ctx->page.front)++ = c;
+ *ctx->page.front = 0;
}
void uw_writec(uw_context ctx, char c) {
- uw_check(ctx, 1);
+ uw_check(ctx, 2);
uw_writec_unsafe(ctx, c);
}
@@ -3144,6 +3147,9 @@ void uw_commit(uw_context ctx) {
if (ctx->transactionals[i].free)
ctx->transactionals[i].free(ctx->transactionals[i].data, 0);
+ if (*ctx->page.front)
+ uw_writec(ctx, 0);
+
// Splice script data into appropriate part of page
if (ctx->returning_indirectly || ctx->script_header[0] == 0) {
char *start = strstr(ctx->page.start, "<sc>");