Mercurial > urweb
changeset 321:cd4cabaf3e52
Fix memory management bug
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 11 Sep 2008 12:12:22 -0400 |
parents | 132416711463 |
children | aa89b73d83e4 |
files | src/c/urweb.c |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/c/urweb.c Thu Sep 11 11:53:33 2008 -0400 +++ b/src/c/urweb.c Thu Sep 11 12:12:22 2008 -0400 @@ -145,7 +145,7 @@ static void uw_check_heap(uw_context ctx, size_t extra) { if (ctx->heap_back - ctx->heap_front < extra) { - size_t desired = ctx->heap_back - ctx->heap + extra, next; + size_t desired = ctx->heap_front - ctx->heap + extra, next; char *new_heap; next = ctx->heap_back - ctx->heap; @@ -154,7 +154,7 @@ for (; next < desired; next *= 2); new_heap = realloc(ctx->heap, next); - ctx->heap_front = new_heap + (ctx->heap_back - ctx->heap_front); + ctx->heap_front = new_heap + (ctx->heap_front - ctx->heap); ctx->heap_back = new_heap + next; if (new_heap != ctx->heap) { @@ -195,7 +195,7 @@ } static void uw_check(uw_context ctx, size_t extra) { - size_t desired = ctx->page_back - ctx->page + extra, next; + size_t desired = ctx->page_front - ctx->page + extra, next; char *new_page; next = ctx->page_back - ctx->page; @@ -578,7 +578,7 @@ } void uw_Basis_htmlifyString_w(uw_context ctx, uw_Basis_string s) { - uw_check(ctx, strlen(s) * 5); + uw_check(ctx, strlen(s) * 6); for (; *s; s++) { char c = *s;