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.

cmStack.h 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef cmStack_h
  2. #define cmStack_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkStRC = cmOkRC,
  9. kLHeapFailStRC,
  10. kInvalidIdxStRC,
  11. kUnderflowStRC
  12. };
  13. typedef cmRC_t cmStRC_t;
  14. typedef cmHandle_t cmStackH_t;
  15. extern cmStackH_t cmStackNullHandle;
  16. // Allocate a stack to hold data elements each of size 'eleByteCnt'.
  17. // The stack will be initialized with 'initCnt' empty slots. Once these
  18. // slots are filled 'expandCnt' additional slots will be added as necessary.
  19. cmStRC_t cmStackAlloc( cmCtx_t* ctx, cmStackH_t* hp, unsigned initCnt, unsigned expandCnt, unsigned eleByteCnt );
  20. cmStRC_t cmStackFree( cmStackH_t* hp );
  21. cmStRC_t cmStackIsValid( cmStackH_t h );
  22. // Return the current count of elements on the stack.
  23. unsigned cmStackCount( cmStackH_t h );
  24. // Empty the stack. Set release flag to also release any memory used by the data elements.
  25. void cmStackClear( cmStackH_t h, bool releaseFl );
  26. // Push 'dataEleCnt' elments onto the stack.
  27. cmStRC_t cmStackPush( cmStackH_t h, const void* data, unsigned dataEleCnt );
  28. // Remove 'eleCnt' elements from the stack.
  29. cmStRC_t cmStackPop( cmStackH_t h, unsigned eleCnt );
  30. // Return a pointer to the top element on the stack. This is the one which will be
  31. // lost with the next call to cmStackPop(h,1).
  32. const void* cmStackTop( cmStackH_t h );
  33. // Set the value of 'dataEleCnt' elements on the stack.
  34. cmStRC_t cmStackSet( cmStackH_t h, unsigned index, const void* data, unsigned dataEleCnt );
  35. // Copy 'dataEleCnt' elements into the buffer pointed to by 'data'.
  36. cmStRC_t cmStackGetN( cmStackH_t h, unsigned index, void* data, unsigned dataEleCnt );
  37. // Return a pointer to a single element on the stack.
  38. const void* cmStackGet( cmStackH_t h, unsigned index );
  39. // Convert the internal representation of the stack to a linear array and return
  40. // a pointer to the array base.
  41. void* cmStackFlatten( cmStackH_t h );
  42. // Stack test function.
  43. void cmStackTest( cmCtx_t* ctx );
  44. #define cmStackEle(h,t,i) (*(t*)cmStackGet(h,i))
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif