libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmArray.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #define cmArrayBase(t,h) ((t*)cmArrayGet(h,0))
  34. #define cmArrayEle(t,h,i) (*(t*)cmArrayGet(h,i))
  35. #define cmArrayClr(t,h,i) ((t*)cmArraySet(h,i,NULL,1))
  36. #define cmArrayClrN(t,h,i,n) ((t*)cmArraySet(h,i,NULL,n))
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif