shmalloc.h File Reference

#include "sharedmem.h"

Include dependency graph for debian/tmp/usr/include/shmalloc.h:

Go to the source code of this file.

Data Structures

struct  _sharedmem_block_t
struct  _sharedmem_alloc_t

Defines

#define SHAREDMEM_ALIGN   8
#define SHAREDMEM_BLOCK_INUSE   0x1
#define SHAREDMEM_FLAGS_MASK   0x1
#define SHMALLOC_SHAREDMEM(i)   ((i)->shminst)

Typedefs

typedef _sharedmem_block_t sharedmem_block_t
typedef _sharedmem_alloc_t sharedmem_alloc_t

Functions

int sharedmem_alloc_create (sharedmem_alloc_t *inst, sharedmem_t *shminst)
long sharedmem_alloc (sharedmem_alloc_t *inst, size_t size)
long sharedmem_realloc (sharedmem_alloc_t *inst, long old_offset, size_t size)
int sharedmem_free (sharedmem_alloc_t *inst, long offset)
void * sharedmem_alloc_get_ptr (sharedmem_alloc_t *inst, long offset)
int sharedmem_alloc_grow (sharedmem_alloc_t *inst, size_t new_size)
void sharedmem_alloc_list_allocs (sharedmem_alloc_t *inst)
void sharedmem_alloc_list_frees (sharedmem_alloc_t *inst)


Define Documentation

#define SHAREDMEM_ALIGN   8

Align has to be big enough to hold block flags

Definition at line 36 of file debian/tmp/usr/include/shmalloc.h.

#define SHAREDMEM_BLOCK_INUSE   0x1

Flags for blocks.

Definition at line 39 of file debian/tmp/usr/include/shmalloc.h.

#define SHAREDMEM_FLAGS_MASK   0x1

Mask for flags.

Definition at line 42 of file debian/tmp/usr/include/shmalloc.h.

#define SHMALLOC_SHAREDMEM (  )     ((i)->shminst)

Get pointer to shared memory object.

Definition at line 70 of file debian/tmp/usr/include/shmalloc.h.


Typedef Documentation

typedef struct _sharedmem_alloc_t sharedmem_alloc_t

Allocator descriptor.

typedef struct _sharedmem_block_t sharedmem_block_t

Allocation block control structure.


Function Documentation

long sharedmem_alloc ( sharedmem_alloc_t inst,
size_t  size 
)

Allocate arbitrary sized block from shared memory.

Parameters:
inst Instance of shared memory allocator object
size Size of block to allocate
Returns:
offset to shared memory

Definition at line 379 of file shmalloc.c.

int sharedmem_alloc_create ( sharedmem_alloc_t inst,
sharedmem_t shminst 
)

Initialize allocator on shared memory.

Parameters:
inst Instance of shared memory allocator object
shminst Instance of shared memory object
Returns:
0 on success

Definition at line 350 of file shmalloc.c.

void* sharedmem_alloc_get_ptr ( sharedmem_alloc_t inst,
long  offset 
)

Get mapped pointer for offset.

Parameters:
inst Instance of shared memory allocator object.
offset Offset to get pointer for
Returns:
mapped pointer

Definition at line 492 of file shmalloc.c.

int sharedmem_alloc_grow ( sharedmem_alloc_t inst,
size_t  new_size 
)

Grow the parent shared memory block and reflect the change in allocator.

Parameters:
inst Instance of sharedmemory allocator object.
new_size New size of the block
Returns:
0 on success

Definition at line 501 of file shmalloc.c.

void sharedmem_alloc_list_allocs ( sharedmem_alloc_t inst  ) 

Print list of allocations to stderr.

Parameters:
inst Instance of shared memory allocator object.

Definition at line 538 of file shmalloc.c.

void sharedmem_alloc_list_frees ( sharedmem_alloc_t inst  ) 

Print list of free areas to stderr.

Parameters:
inst Instance of shared memory allocator object.

Definition at line 562 of file shmalloc.c.

int sharedmem_free ( sharedmem_alloc_t inst,
long  offset 
)

Free previously allocated shared memory block.

Parameters:
inst Instance of shared memory allocator object.
offset Offset to free
Returns:
0 on success

Definition at line 474 of file shmalloc.c.

long sharedmem_realloc ( sharedmem_alloc_t inst,
long  old_offset,
size_t  size 
)

Reallocate block from shared memory.

Note:
The offset may change depending on availability of free space.
Parameters:
inst Instance of shared memory allocator object
old_offset Offset to reallocate
size New size for the block
Returns:
offset to reallocated block

Definition at line 399 of file shmalloc.c.


Generated on Thu Sep 13 18:14:39 2007 for libsharedmem by  doxygen 1.5.1