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.

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