libcm is a C development framework with an emphasis on audio signal processing applications.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

cmArray.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Returns a pointer to the first pushed element.
  24. // Set 'data' to NULL to create 'dataEleCnt' new zeroed elements.
  25. void* cmArrayPush( cmArrayH_t h, const void* data, unsigned dataEleCnt );
  26. // Decreaese the array count by 'eleCnt'.
  27. cmArRC_t cmArrayPop( cmArrayH_t h, unsigned eleCnt );
  28. // If 'data' is NULL then array[idx:idx+dataEleCnt] is zeroed.
  29. // Returns a ptr to the first set element.
  30. void* cmArraySet( cmArrayH_t h, unsigned index, const void* data, unsigned dataEleCnt );
  31. const void* cmArrayGet( cmArrayH_t h, unsigned index );
  32. #define cmArrayPtr(t,h,i) ((t*)cmArrayGet(h,i))
  33. // Return a ptr to the base of the array.
  34. #define cmArrayBase(t,h) ((t*)cmArrayGet(h,0))
  35. // Return a ptr to the ith element
  36. #define cmArrayEle(t,h,i) (*(t*)cmArrayGet(h,i))
  37. // Zero the ith element
  38. #define cmArrayClr(t,h,i) ((t*)cmArraySet(h,i,NULL,1))
  39. // Zero elements i:i+n-1
  40. #define cmArrayClrN(t,h,i,n) ((t*)cmArraySet(h,i,NULL,n))
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif