Defines | Typedefs | Functions

memory pool
[LIM utility library]

Defines

#define OBJECT_MEMORY_ALIGNED_BYTES(bytes)   ((((bytes) + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *))

Typedefs

typedef void * lim_mem_pool_t

Functions

lim_mem_pool_t lim_mem_pool_create (int bytes)
void lim_mem_pool_destroy (lim_mem_pool_t pool)
void lim_mem_pool_reset (lim_mem_pool_t pool)
void * lim_mem_pool_get_buf (lim_mem_pool_t pool, int bytes)
int lim_mem_pool_put_buf (lim_mem_pool_t pool, void *ptr)
int lim_mem_pool_hold_buf (lim_mem_pool_t pool, void *ptr)

Define Documentation

#define OBJECT_MEMORY_ALIGNED_BYTES (   bytes  )     ((((bytes) + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *))

calculate object alignment byte count.


Typedef Documentation

typedef void* lim_mem_pool_t

opaque lim memory pool handle.


Function Documentation

lim_mem_pool_t lim_mem_pool_create ( int  bytes  ) 

create memory pool.

Parameters:
bytes number of bytes in pool.
Returns:
memory pool handle if successful, otherwise NULL.
void lim_mem_pool_destroy ( lim_mem_pool_t  pool  ) 

destroy memory pool.

Parameters:
pool memory pool handle returned by lim_mem_pool_create().
void* lim_mem_pool_get_buf ( lim_mem_pool_t  pool,
int  bytes 
)

get 'bytes' memory from memory pool.

Parameters:
pool memory pool handle returned by lim_mem_pool_create().
bytes requested bytes.
Returns:
pointer to memory if successful, otherwise NULL.
int lim_mem_pool_hold_buf ( lim_mem_pool_t  pool,
void *  ptr 
)

hold memory buffer. increase memory reference counter.

Parameters:
pool memory pool handle returned by lim_mem_pool_create().
ptr memory pointer.
Returns:
current reference counter of ptr, error if value is less than 2.
int lim_mem_pool_put_buf ( lim_mem_pool_t  pool,
void *  ptr 
)

pet memory back to memory pool. decrease memory reference counter, and put memory back to pool if reference counter goes down to zero.

Parameters:
pool memory pool handle returned by lim_mem_pool_create().
ptr memory pointer.
Returns:
current reference counter of ptr, negative value for error.
void lim_mem_pool_reset ( lim_mem_pool_t  pool  ) 

reset memory pool. invalidate all pointers allocated from pool.

Parameters:
pool memory pool handle returned by lim_mem_pool_create().
LIMOpenMAX Implementation API Reference - Generated by doxygen