diff options
-rw-r--r-- | src/c/request.c | 4 | ||||
-rw-r--r-- | src/c/urweb.c | 6 | ||||
-rw-r--r-- | tests/listinit.ur | 43 |
3 files changed, 48 insertions, 5 deletions
diff --git a/src/c/request.c b/src/c/request.c index 813d967c..5aee7bbe 100644 --- a/src/c/request.c +++ b/src/c/request.c @@ -212,10 +212,10 @@ void uw_request_init(uw_app *app, uw_loggers* ls) { } -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 --git a/src/c/urweb.c b/src/c/urweb.c index 78afcd05..10bbf930 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1264,8 +1264,8 @@ void uw_end_initializing(uw_context ctx) { 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; } @@ -1280,7 +1280,7 @@ void *uw_malloc(uw_context ctx, size_t len) { 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 --git a/tests/listinit.ur b/tests/listinit.ur new file mode 100644 index 00000000..8f9fb57d --- /dev/null +++ b/tests/listinit.ur @@ -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 + :: 1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 ::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