libcm/cmArray.h

42 lines
1.2 KiB
C
Raw Normal View History

2013-03-21 15:16:10 +00:00
#ifndef cmArray_h
#define cmArray_h
#ifdef __cplusplus
extern "C" {
#endif
enum
{
kOkArRC = cmOkRC,
kUnderflowArRC
};
typedef cmRC_t cmArRC_t;
typedef cmHandle_t cmArrayH_t;
extern cmArrayH_t cmArrayNullHandle;
cmArRC_t cmArrayAlloc( cmCtx_t* ctx, cmArrayH_t* hp, unsigned eleByteCnt, unsigned initCnt, unsigned expandCnt );
cmArRC_t cmArrayRelease(cmArrayH_t* hp );
cmArRC_t cmArrayIsValid(cmArrayH_t h );
unsigned cmArrayCount( cmArrayH_t h );
cmArRC_t cmArrayClear( cmArrayH_t h, bool releaseFl );
void* cmArrayPush( cmArrayH_t h, const void* data, unsigned dataEleCnt );
cmArRC_t cmArrayPop( cmArrayH_t h, unsigned eleCnt );
// If 'data' is NULL then array[idx:idx+dataEleCnt] is zeroed.
void* cmArraySet( cmArrayH_t h, unsigned index, const void* data, unsigned dataEleCnt );
const void* cmArrayGet( cmArrayH_t h, unsigned index );
#define cmArrayPtr(t,h,i) ((t*)cmArrayGet(h,i))
#define cmArrayEle(t,h,i) (*(t*)cmArrayGet(h,i))
#define cmArrayClr(t,h,i) ((t*)cmArraySet(h,i,NULL,1))
#define cmArrayClrN(t,h,i,n) ((t*)cmArraySet(h,i,NULL,n))
#ifdef __cplusplus
}
#endif
#endif