X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=runtime%2Fmem.c;h=708ef22ed94f5526b1b5cb23de73b1f21c8d73fc;hp=e46eb7efbd8bf8278ba786666012e753bf6e9650;hb=010e49988a8b12f78053c387b3798763b4e8df18;hpb=053576b00e7d37f19ce99f033e9981761d647c1f diff --git a/runtime/mem.c b/runtime/mem.c index e46eb7e..708ef22 100644 --- a/runtime/mem.c +++ b/runtime/mem.c @@ -62,6 +62,7 @@ void mem_init (void) { // // TODO: maybe we want to munmap() larger size blocks to reclaim virtual address space? void nbd_free (void *x) { + assert(x); LOCALIZE_THREAD_LOCAL(tid_, int); block_t *b = (block_t *)x; assert(((size_t)b >> REGION_SCALE) < ((1 << HEADER_REGION_SCALE) / sizeof(header_t))); @@ -88,6 +89,7 @@ void nbd_free (void *x) { // on the private free list. If we didn't find any blocks on the public free lists, allocate a new // region, break it up into blocks and put them on the private free list. void *nbd_malloc (size_t n) { + assert(n); LOCALIZE_THREAD_LOCAL(tid_, int); if (n < sizeof(block_t)) { n = sizeof(block_t); @@ -111,9 +113,9 @@ void *nbd_malloc (size_t n) { uint32_t count = pri->count; pri->count = 0; // If our private list is empty and we haven't gotten at least half a region's worth - // of block's from our public lists, we break open a new region. This guarentees - // that we are amortizing the cost of accessing our public lists accross enough - // nbd_malloc() calls. + // of block's from our public lists, we allocate a new region. This guarentees that + // we amortize the cost of accessing our public lists accross enough nbd_malloc() + // calls. uint32_t min_count = b_scale > REGION_SCALE ? 1 << (b_scale-REGION_SCALE-1) : 1; if (count < min_count) { char *region = get_new_region(b_scale);