libcm is a C development framework with an emphasis on audio signal processing applications.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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