libcm is a C development framework with an emphasis on audio signal processing applications.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cmArray.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef cmArray_h
  2. #define cmArray_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkArRC = cmOkRC,
  9. kUnderflowArRC
  10. };
  11. typedef cmRC_t cmArRC_t;
  12. typedef cmHandle_t cmArrayH_t;
  13. extern cmArrayH_t cmArrayNullHandle;
  14. cmArRC_t cmArrayAlloc0( cmCtx_t* ctx, cmArrayH_t* hp, unsigned eleByteCnt, unsigned initCnt, unsigned expandCnt );
  15. // Defaults initCnt and expandCnt to 10.
  16. cmArRC_t cmArrayAlloc( cmCtx_t* ctx, cmArrayH_t* hp, unsigned eleByteCnt );
  17. cmArRC_t cmArrayRelease(cmArrayH_t* hp );
  18. cmArRC_t cmArrayIsValid(cmArrayH_t h );
  19. void cmArraySetExpandCount( cmArrayH_t h, unsigned expandCnt );
  20. unsigned cmArrayExpandCount( cmArrayH_t h );
  21. unsigned cmArrayCount( cmArrayH_t h );
  22. cmArRC_t cmArrayClear( cmArrayH_t h, bool releaseFl );
  23. void* cmArrayPush( cmArrayH_t h, const void* data, unsigned dataEleCnt );
  24. cmArRC_t cmArrayPop( cmArrayH_t h, unsigned eleCnt );
  25. // If 'data' is NULL then array[idx:idx+dataEleCnt] is zeroed.
  26. void* cmArraySet( cmArrayH_t h, unsigned index, const void* data, unsigned dataEleCnt );
  27. const void* cmArrayGet( cmArrayH_t h, unsigned index );
  28. #define cmArrayPtr(t,h,i) ((t*)cmArrayGet(h,i))
  29. #define cmArrayBase(t,h) ((t*)cmArrayGet(h,0))
  30. #define cmArrayEle(t,h,i) (*(t*)cmArrayGet(h,i))
  31. #define cmArrayClr(t,h,i) ((t*)cmArraySet(h,i,NULL,1))
  32. #define cmArrayClrN(t,h,i,n) ((t*)cmArraySet(h,i,NULL,n))
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #endif