bpo_alloc - Shared Memory Allocation Routines

The bpo_alloc module provides dynamic shared memory allocation in an almost identical manner to that provided by the system standard routines malloc() and free(). The only variation is in the replacement for the malloc call which requires a hint as to which shared memory segment the allocation should take place in.


    extern void *shalloc( void *hint, size_t size );
This routine takes a hint and a size parameter. If the allocation is successful, the routine returns a pointer to the allocated block. If the routine fails to allocate (the segment does not support allocation, or there is no resource left) then it returns NULL.

    extern void shfree( void *ptr );
This routine takes a pointer to a previously allocated block, and returns the block to the free list. If the pointer is not to a previously allocated block then the call silently fails.


Additionally there are pair of support routines which provide string duplication into shared memory.

    char *bpo_strdup( void *hint, const char *s1 );

    off_t bpo_strdup_offset( void *hint, const char *s1 );
These routines allocate a block of memory in the shared memory region pointed to by hint and if successful, copy the supplied string into the new block and return either a pointer to the new string or the offset of the allocated block within the region.