X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fbigalloc.c;h=0044846d5d541fb06a03c56f90df8715a0898e2b;hb=bc5f818d21b7aceaf2c0e263b00aa4295211d8f9;hp=7532a446239bb11b320455a7059f63053c8be306;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/bigalloc.c b/ucw/bigalloc.c index 7532a446..0044846d 100644 --- a/ucw/bigalloc.c +++ b/ucw/bigalloc.c @@ -8,7 +8,7 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" +#include #include #include @@ -17,6 +17,8 @@ void * page_alloc(u64 len) { + if (!len) + return NULL; if (len > SIZE_MAX) die("page_alloc: Size %llu is too large for the current architecture", (long long) len); ASSERT(!(len & (CPU_PAGE_SIZE-1))); @@ -63,11 +65,11 @@ big_alloc(u64 len) u64 l = big_round(len); if (l > SIZE_MAX - 2*CPU_PAGE_SIZE) die("big_alloc: Size %llu is too large for the current architecture", (long long) len); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG l += 2*CPU_PAGE_SIZE; #endif byte *p = page_alloc(l); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG *(u64*)p = len; mprotect(p, CPU_PAGE_SIZE, PROT_NONE); mprotect(p+l-CPU_PAGE_SIZE, CPU_PAGE_SIZE, PROT_NONE); @@ -89,7 +91,7 @@ big_free(void *start, u64 len) { byte *p = start; u64 l = big_round(len); -#ifdef CONFIG_DEBUG +#ifdef CONFIG_UCW_DEBUG p -= CPU_PAGE_SIZE; mprotect(p, CPU_PAGE_SIZE, PROT_READ); ASSERT(*(u64*)p == len);