From 04e20a64e414abe03cae15767efda974231eb622 Mon Sep 17 00:00:00 2001 From: Jean-Paul Mari Date: Sat, 10 Oct 2020 01:58:56 -0400 Subject: [PATCH] Update tinyalloc.c Fix Visual Studio compilation error. --- tinyalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinyalloc.c b/tinyalloc.c index eb9fa3f..9339643 100644 --- a/tinyalloc.c +++ b/tinyalloc.c @@ -159,7 +159,7 @@ static Block *alloc_block(size_t num) { Block *ptr = heap->free; Block *prev = NULL; size_t top = heap->top; - num = (num + heap_alignment - 1) & -heap_alignment; + num = (num + heap_alignment - 1) & (0 - heap_alignment); while (ptr != NULL) { const int is_top = ((size_t)ptr->addr + ptr->size >= top) && ((size_t)ptr->addr + num <= (size_t)heap_limit); if (is_top || ptr->size >= num) { @@ -223,7 +223,7 @@ void *ta_alloc(size_t num) { static void memclear(void *ptr, size_t num) { size_t *ptrw = (size_t *)ptr; - size_t numw = (num & -sizeof(size_t)) / sizeof(size_t); + size_t numw = (num & (0 - sizeof(size_t))) / sizeof(size_t); while (numw--) { *ptrw++ = 0; }