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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. // mmFlags take the same values as the flags parameter to cmMmReport().
  30. cmMmRC_t cmLHeapReportErrors( cmLHeapH_t h, unsigned mmFlags );
  31. void cmLHeapReport( cmLHeapH_t h );
  32. void cmLHeapTest();
  33. #if cmDEBUG_FL == 0
  34. #define cmLHeapAlloc( h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl, NULL,NULL,0)
  35. #define cmLHeapAllocZ(h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl | kZeroMmFl, NULL,NULL,0)
  36. #define cmLhAlloc(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl, NULL,NULL,0))
  37. #define cmLhAllocZ(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl | kZeroMmFl, NULL,NULL,0))
  38. #define cmLhResizeN( h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl, NULL,NULL,0))
  39. #define cmLhResizeNZ(h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl | kZeroMmFl, NULL,NULL,0))
  40. #define cmLhAllocStr( h, str ) cmLHeapAllocStr( h, NULL, str, strlen(str), kAlignMmFl, NULL,NULL,0 )
  41. #define cmLhAllocStrN( h, str, n ) cmLHeapAllocStr( h, NULL, str, n, kAlignMmFl, NULL,NULL,0 )
  42. #define cmLhResizeStr( h, p, str ) cmLHeapAllocStr( h, p, str, strlen(str), kAlignMmFl, NULL,NULL,0 )
  43. #define cmLhResizeStrN( h, p, str, n ) cmLHeapAllocStr( h, p, str, n, kAlignMmFl, NULL,NULL,0 )
  44. #define cmLhFree( h, p ) cmLHeapFree( h, p )
  45. #define cmLhFreePtr(h, p ) cmLHeapFreePtr( h, p )
  46. #else
  47. #define cmLHeapAlloc( h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__)
  48. #define cmLHeapAllocZ(h, byteCnt ) cmLHeapAllocate(h,NULL,1,byteCnt, kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__)
  49. #define cmLhAlloc(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__))
  50. #define cmLhAllocZ(h,t,n) ((t*)cmLHeapAllocate(h,NULL,n,sizeof(t), kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__))
  51. #define cmLhResizeN( h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__))
  52. #define cmLhResizeNZ(h,t,p,n) ((t*)cmLHeapAllocate(h,p, n,sizeof(t), kAlignMmFl | kZeroMmFl, __FILE__,__FUNCTION__,__LINE__))
  53. #define cmLhAllocStr( h, str ) cmLHeapAllocStr( h, NULL, str, strlen(str), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  54. #define cmLhAllocStrN( h, str, n ) cmLHeapAllocStr( h, NULL, str, n, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  55. #define cmLhResizeStr( h, p, str ) cmLHeapAllocStr( h, p, str, strlen(str), kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  56. #define cmLhResizeStrN( h, p, str, n ) cmLHeapAllocStr( h, p, str, n, kAlignMmFl, __FILE__,__FUNCTION__,__LINE__ )
  57. #define cmLhFree( h, p ) cmLHeapFreeDebug( h, p, __FILE__,__FUNCTION__,__LINE__ )
  58. #define cmLhFreePtr(h, p ) cmLHeapFreePtrDebug( h, p, __FILE__,__FUNCTION__,__LINE__ )
  59. #endif
  60. //)
  61. //}
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif