# HG changeset patch # User Adam Chlipala # Date 1401292399 14400 # Node ID bcda3ae886771d9aaef028246608392860b48c59 # Parent 3ed2ee0815d27ae9551aedc25ba79a625b684214 Align to sizeof(void *) instead of fixed 4 diff -r 3ed2ee0815d2 -r bcda3ae88677 src/c/request.c --- a/src/c/request.c Sun May 25 09:21:56 2014 -0400 +++ b/src/c/request.c Wed May 28 11:53:19 2014 -0400 @@ -212,10 +212,10 @@ } -typedef struct uw_rc { +struct uw_rc { size_t path_copy_size, queryString_size; char *path_copy, *queryString; -} *uw_request_context; +}; uw_request_context uw_new_request_context(void) { uw_request_context r = malloc(sizeof(struct uw_rc)); diff -r 3ed2ee0815d2 -r bcda3ae88677 src/c/urweb.c --- a/src/c/urweb.c Sun May 25 09:21:56 2014 -0400 +++ b/src/c/urweb.c Wed May 28 11:53:19 2014 -0400 @@ -1259,8 +1259,8 @@ static void align_heap(uw_context ctx) { size_t posn = ctx->heap.front - ctx->heap.start; - if (posn % 4 != 0) { - size_t bump = 4 - posn % 4; + if (posn % sizeof(void *) != 0) { + size_t bump = sizeof(void *) - posn % sizeof(void *); uw_check_heap(ctx, bump); ctx->heap.front += bump; } @@ -1275,7 +1275,7 @@ void *result; if (ctx->amInitializing) { - int error = posix_memalign(&result, 4, len); + int error = posix_memalign(&result, sizeof(void *), len); if (!error) return result; diff -r 3ed2ee0815d2 -r bcda3ae88677 tests/listinit.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/listinit.ur Wed May 28 11:53:19 2014 -0400 @@ -0,0 +1,43 @@ +fun makeList n = + if n = 0 then + [] + else + n :: makeList (n-1) + +fun sum ls = + case ls of + [] => 0 + | n :: ls' => n + sum ls' + +val ls = 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 + :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 + :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 +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