Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
Dynamic memory handling.

Detailed Description

See also
Barracuda Introduction

Classes

struct  FixedSizeAllocator
 This is a fixed size allocator implementation for the abstract interface class AllocatorIntf. More...
 

Typedefs

typedef FixedSizeAllocator FixedSizeAllocator
 This is a fixed size allocator implementation for the abstract interface class AllocatorIntf. More...
 

Functions

void * baMalloc (size_t size)
 Allocate uninitialized storage using the target's configured allocator. More...
 
void * baRealloc (void *p, size_t size)
 Resize storage using the target's configured allocator. More...
 
void baFree (void *p)
 Release storage using the target's configured allocator. More...
 

Typedef Documentation

◆ FixedSizeAllocator

This is a fixed size allocator implementation for the abstract interface class AllocatorIntf.

The FixedSizeAllocator takes a buffer and splits the buffer up into equally sized chunks. Allocating memory larger than the chunk size or using realloc results in an error; i.e., NULL returned. One can allocate a smaller size than the chunk size, but the size will be adjusted to the chunk size. A zero-size request or exhausted pool returns NULL and sets the requested size to zero. Free only live blocks returned by this allocator, once each; NULL is not accepted. The backing buffer remains owned by the caller and must outlive the allocator and all allocated blocks. This allocator does not lock access; callers must serialize concurrent use.

Function Documentation

◆ baFree()

void baFree ( void *  p)

Release storage using the target's configured allocator.

Parameters
[in]pLive block from baMalloc or baRealloc. NULL handling follows the target's allocator. Do not access the block after this call.

◆ baMalloc()

void * baMalloc ( size_t  size)

Allocate uninitialized storage using the target's configured allocator.

Parameters
[in]sizeRequested bytes. Zero-size behavior is platform-dependent.
Returns
Owned block or NULL on failure; release with baFree.

◆ baRealloc()

void * baRealloc ( void *  p,
size_t  size 
)

Resize storage using the target's configured allocator.

Parameters
[in]pExisting allocation from this allocator, or NULL.
[in]sizeRequested bytes. Use a positive value for portable behavior; zero-size behavior follows the target's allocator.
Returns
Replacement block preserving the smaller old/new byte count, or NULL on failure. For a positive size, failure preserves p; success consumes the old block. Newly added bytes are uninitialized.