Go to the source code of this file.
Defines | |
#define | ctl_fp_decl(type, count, label) |
Declare a fixed pool of type. | |
#define | ctl_fp_init(label, instance) |
Initialize a fixed pool of type. | |
#define | ctl_fp_valid(label, instance, ptr) memberof((instance)->data,(ppConcat(label,_type)*)(ptr)) |
Validate a pointer from a fixed pool;. | |
#define | ctl_fp_index(label, instance, ptr) indexof((instance)->data,(ppConcat(label,_type)*)(ptr)) |
Return the index of a pointer allocated from a pool Useful for certain constructs where we need unique identifiers for objects Returns the item whether it's free or not, so mark it 'used' in your data somehow wrap this. | |
#define | ctl_fp_lut(label, instance, index) ( ((unsigned)(index) < sizeof(instance->data)) ? instance->data + (index) : NULL ) |
Return the pointer to an object in the pool from an index Useful for certain constructs where we need unique identifiers for objects Returns the item whether it's free or not, so mark it 'used' in your data somehow and wrap this. | |
#define | ctl_fp_alloc(label, instance, result) |
Allocate a pointer of type from fixed pool. | |
#define | ctl_fp_calloc(label, instance, result) |
Allocate a pointer of type from fixed pool, clear it. | |
#define | ctl_fp_free(label, instance, ptr) |
Free a pointer of type back to fixed pool. |
Definition in file pool.h.
#define ctl_fp_alloc | ( | label, | |||
instance, | |||||
result | ) |
Value:
{\ (result) = (ppConcat(label,_type)*)(instance)->free;\ /* Assert: memory link damage? */\ assert( NULL == (result) || ctl_fp_valid(label, instance, (result) ) );\ if( (instance)->free )\ (instance)->free = (instance)->free->free;\ }
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
result | A void pointer to receive the anonymous data |
#define ctl_fp_calloc | ( | label, | |||
instance, | |||||
result | ) |
Value:
{\ ctl_fp_alloc(label, instance, result );\ memset((result),0,sizeof(ppConcat(label,_type)));\ }
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
result | A void pointer to receive the anonymous data |
Definition at line 97 of file pool.h.
Referenced by Socket_Create().
#define ctl_fp_decl | ( | type, | |||
count, | |||||
label | ) |
Value:
typedef type ppConcat(label,_type);\ struct ppConcat(label,_freenode)\ {\ struct ppConcat(label,_freenode)* free;\ };\ typedef struct label\ {\ struct ppConcat(label,_freenode)* free;\ type data[count];\ } label;
type | Template: Type of compound data this allocates | |
count | Template: Count of available blocks of data | |
label | What to name the type we've manufactured |
#define ctl_fp_free | ( | label, | |||
instance, | |||||
ptr | ) |
Value:
{\ if( (ptr) )\ {\ struct ppConcat(label,_freenode)* fpipfree = (struct ppConcat(label,_freenode)*)(ptr);\ /* Assert: Memory pointer must belong to this pool */\ assert( ctl_fp_valid(label, instance, ptr ) );\ fpipfree->free = (instance)->free;\ (instance)->free = fpipfree;\ (ptr) = NULL;\ }\ }
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
ptr | A void pointer of 'type' that came from ctl_fp_alloc, it will be set to NULL as a side-effect |
#define ctl_fp_index | ( | label, | |||
instance, | |||||
ptr | ) | indexof((instance)->data,(ppConcat(label,_type)*)(ptr)) |
Return the index of a pointer allocated from a pool Useful for certain constructs where we need unique identifiers for objects Returns the item whether it's free or not, so mark it 'used' in your data somehow wrap this.
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
ptr | A pointer that came from ctl_fp_alloc |
Definition at line 63 of file pool.h.
Referenced by Socket_Create(), and Socket_Customize().
#define ctl_fp_init | ( | label, | |||
instance | ) |
Value:
{\ size_t fpicurr = countof((instance)->data);\ (instance)->free = NULL;\ while( fpicurr-- )\ {\ struct ppConcat(label,_freenode)* fpipCurr = (struct ppConcat(label,_freenode)*) ((instance)->data + fpicurr);\ fpipCurr->free = (instance)->free;\ (instance)->free = fpipCurr;\ }\ }
label | Template: Type of allocator | |
instance | Pointer to fixed pool |
Definition at line 33 of file pool.h.
Referenced by SocketsInit().
#define ctl_fp_lut | ( | label, | |||
instance, | |||||
index | ) | ( ((unsigned)(index) < sizeof(instance->data)) ? instance->data + (index) : NULL ) |
Return the pointer to an object in the pool from an index Useful for certain constructs where we need unique identifiers for objects Returns the item whether it's free or not, so mark it 'used' in your data somehow and wrap this.
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
index | An index into the pool |
Definition at line 74 of file pool.h.
Referenced by SocketLut().
#define ctl_fp_valid | ( | label, | |||
instance, | |||||
ptr | ) | memberof((instance)->data,(ppConcat(label,_type)*)(ptr)) |
Validate a pointer from a fixed pool;.
label | Template: Type of allocator | |
instance | Pointer to fixed pool | |
ptr | A void pointer that came from ctl_fp_alloc |
Definition at line 52 of file pool.h.
Referenced by SocketID().