darenainit — dmalloc API manual page

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | STANDARDS | NOTES

darenainit                dmalloc API functions manual                darenainit

NAME         top

        darenainit - initializes an arena.

SYNOPSIS         top


        #include "dmalloc.h"

        int darenainit(void* backing_memory, size_t capacity);

DESCRIPTION         top

        The function darenainit() initializes the memory region pointed to by 
        backing_memory and of size capacity to an arena. If backing_memory is 
        NULL, the function just returns 0.   

RETURN VALUE         top

        On success, darenainit() returns 0. On failure, it returns -1, and sets
        errno.

ERRORS         top

        ENOMEM  Out of memory. darenainit() failed because capacity was not big 
                enough for a properly initialized arena.

ATTRIBUTES         top

        For an explanation of the terms used in this section, see attributes(7).
        ┌────────────────────────────────────┬───────────────┬───────────┐
        │ InterfaceAttributeValue     │
        ├────────────────────────────────────┼───────────────┼───────────┤
        │ arenainit()                        │ Thread safety │ MT-Unsafe │
        └────────────────────────────────────┴───────────────┴───────────┘

STANDARDS         top

        None.

NOTES         top

        Trying to initialize an arena more than once is considered unsafe. It
        can still be done in single-threaded applications, because the critical 
        step of arena initialization deals with mutexes, but it does become
        source of undefined behaviour in multi-threaded applications.
        
        Initalizing an arena more that once both includes multiple calls to
        darenainit() on the same backing memory in the same thread and
        sigle calls to such function by different thread at possibly the same
        time.
        
        In any case, note that, after initialization, any arena is safe to be 
        used in a multi-threaded context with all of the other allocator
        functions.
dmalloc API functions manual       2026-04-13                         darenainit