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.

cmLinkedHeap.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef cmLinkedHeap_h
  2. #define cmLinkedHeap_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //{
  7. //(
  8. typedef cmHandle_t cmLHeapH_t;
  9. extern cmLHeapH_t cmLHeapNullHandle;
  10. cmLHeapH_t cmLHeapCreate( unsigned dfltBlockByteCnt, cmCtx_t* ctx );
  11. void cmLHeapDestroy( cmLHeapH_t* hp );
  12. void* cmLHeapAllocate( cmLHeapH_t h, void* orgDataPtr, unsigned eleCnt, unsigned eleByteCnt, unsigned flags, const char* fileStr, const char* funcStr, unsigned fileLine );
  13. cmChar_t* cmLHeapAllocStr( cmLHeapH_t h, void* orgDataPtr, const cmChar_t* str, unsigned charCnt, unsigned flags, const char* fileStr, const char* funcStr, unsigned fileLine );
  14. // If ptr==NULL the function returns with no side effect.
  15. void cmLHeapFree( cmLHeapH_t h, void* ptr );
  16. void cmLHeapFreeDebug( cmLHeapH_t h, void* dataPtr, const char* fileName, const char* funcName, unsigned fileLine );
  17. // If *ptr==NULL the function returns with no side effect.
  18. void cmLHeapFreePtr( cmLHeapH_t h, void** ptrPtr );
  19. void cmLHeapFreePtrDebug( cmLHeapH_t h, void** dataPtrPtr, const char* fileName, const char* funcName, unsigned fileLine );
  20. bool cmLHeapIsValid( cmLHeapH_t h );
  21. // Return the values set in call to cmLHeapCreate()
  22. unsigned cmLHeapDefaultBlockByteCount( cmLHeapH_t h );
  23. unsigned cmLHeapGuardByteCount( cmLHeapH_t h );
  24. unsigned cmLHeapAlignByteCount( cmLHeapH_t h );
  25. unsigned cmLHeapInitializeFlags( cmLHeapH_t h );
  26. // If releaseFl==false then marks all internal memory blocks as empty but does not actually
  27. // release the associated memory, otherwise releases all memory blocks.
  28. void cmLHeapClear( cmLHeapH_t h, bool releaseFl );
  29. // Return true if 'ptr' points into a linked heap block.
  30. bool cmLHeapIsPtrInHeap( cmLHeapH_t h, const void* ptr );
  31. // mmFlags take the same values as the flags parameter to cmMmReport().
  32. cmMmRC_t cmLHeapReportErrors( cmLHeapH_t h, unsigned mmFlags );
  33. void cmLHeapReport( cmLHeapH_t h );
  34. void cmLHeapTest();
  35. #if cmDEBUG_FL == 0
  36. #define cmLHeapAlloc( h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl, NULL,NULL,0)
  37. #define cmLHeapAllocZ(h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl | kZeroMmFl, NULL,NULL,0)
  38. #define cmLhAlloc(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl, NULL,NULL,0))
  39. #define cmLhAllocZ(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl | kZeroMmFl, NULL,NULL,0))
  40. #define cmLhResizeN( h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl, NULL,NULL,0))
  41. #define cmLhResizeNZ(h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl | kZeroMmFl, NULL,NULL,0))
  42. #define cmLhAllocStr( h, str ) cmLHeapAllocStr( h, NULL, str, cmStringLen(str), kAlignMmFl, NULL,NULL,0 )
  43. #define cmLhAllocStrN( h, str, n ) cmLHeapAllocStr( h, NULL, str, n, kAlignMmFl, NULL,NULL,0 )
  44. #define cmLhResizeStr( h, p, str ) cmLHeapAllocStr( h, p, str, cmStringLen(str), kAlignMmFl, NULL,NULL,0 )
  45. #define cmLhResizeStrN( h, p, str, n ) cmLHeapAllocStr( h, p, str, n, kAlignMmFl, NULL,NULL,0 )
  46. #define cmLhFree( h, p ) cmLHeapFree( h, p )
  47. #define cmLhFreePtr(h, p ) cmLHeapFreePtr( h, p )
  48. #else
  49. #define cmLHeapAlloc( h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__)
  50. #define cmLHeapAllocZ(h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__)
  51. #define cmLhAlloc(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__))
  52. #define cmLhAllocZ(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__))
  53. #define cmLhResizeN( h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__))
  54. #define cmLhResizeNZ(h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__))
  55. #define cmLhAllocStr( h, str ) cmLHeapAllocStr( h, NULL, str, cmStringLen(str), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  56. #define cmLhAllocStrN( h, str, n ) cmLHeapAllocStr( h, NULL, str, n, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  57. #define cmLhResizeStr( h, p, str ) cmLHeapAllocStr( h, p, str, cmStringLen(str), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  58. #define cmLhResizeStrN( h, p, str, n ) cmLHeapAllocStr( h, p, str, n, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  59. #define cmLhFree( h, p ) cmLHeapFreeDebug( h, p, __FILE__,__FUNCTION__,__LINE__ )
  60. #define cmLhFreePtr(h, p ) cmLHeapFreePtrDebug( h, p, __FILE__,__FUNCTION__,__LINE__ )
  61. #endif
  62. //)
  63. //}
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif