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.

cmStack.h 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // The top element is at index cmStackCount() - 1.
  35. cmStRC_t cmStackSet( cmStackH_t h, unsigned index, const void* data, unsigned dataEleCnt );
  36. // Copy 'dataEleCnt' elements into the buffer pointed to by 'data'.
  37. // The top element is at index cmStackCount() - 1.
  38. cmStRC_t cmStackGetN( cmStackH_t h, unsigned index, void* data, unsigned dataEleCnt );
  39. // Return a pointer to a single element on the stack.
  40. // The top element is at index cmStackCount() - 1.
  41. const void* cmStackGet( cmStackH_t h, unsigned index );
  42. // Convert the internal representation of the stack to a linear array and return
  43. // a pointer to the array base.
  44. void* cmStackFlatten( cmStackH_t h );
  45. // Stack test function.
  46. void cmStackTest( cmCtx_t* ctx );
  47. #define cmStackEle(h,t,i) (*(t*)cmStackGet(h,i))
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif