PREV UP next StackThreads/MP: version 0.77 User's Guide

4.3.2: Changing Region-based Allocator

Interfaces to region-based memory manager is also wrapped.

        #include <st_mm.h>
@        st_region_t MM_MAKE_REGION();
@        st_region_t MM_MAKE_REGION_AUX(chunk_size, init_size, 
                                        pre_alloc_option, alloc, free);
@        st_region_t MM_MAKE_REGION_HIGHLY_CONCURRENT_1(init_size, 
                                        alloc, free)
@        void * MM_REGION_MALLOC(sz, rg);
@        void MM_REGION_FREE(ptr);
@        void MM_RESET_REGION(rg);
@        void MM_ABANDON_REGION(rg);

They are macros whose behavior change according to the following parameter.

        #define RALLOC ...

RALLOC is either 0 or 1. When RALLOC is 1, all MM_REGION_xxx, except for MM_REGION_FREE(ptr), are equivalent to st_region_xxx. For example, MM_MAKE_REGION() is equivalent to st_make_region(). MM_REGION_FREE(ptr) has no effects. When RALLOC is 0, all MM_REGION_xxx things are redirected to the underlying allocator. For example, MM_REGION_MALLOC(sz, rg) ignores the region parameter and is equivalent to MM_ALLOC(sz). MM_REGION_FREE(ptr) behaves like MM_FREE(ptr).