Showing the changes to codec/common/src/memory_align.cpp (1 of 1 file). Show all
Unified · Split
| @@ -40,6 +40,7 @@ namespace WelsCommon { · 39 unmodified lines | |||
| 40 | #ifdef MEMORY_CHECK | 40 | #ifdef MEMORY_CHECK |
| 41 | static FILE* fpMemChkPoint; | 41 | static FILE* fpMemChkPoint; |
| 42 | static uint32_t nCountRequestNum; | 42 | static uint32_t nCountRequestNum; |
| 43 | static int32_t iMemoryLength; | ||
| 43 | #endif | 44 | #endif |
| 44 | 45 | ||
| 45 | 46 | ||
| @@ -71,8 +72,8 @@ void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAl · 25 unmodified lines | |||
| 71 | uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize); | 72 | uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize); |
| 72 | #ifdef MEMORY_CHECK | 73 | #ifdef MEMORY_CHECK |
| 73 | if (fpMemChkPoint == NULL) { | 74 | if (fpMemChkPoint == NULL) { |
| 74 | m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+"); | 75 | fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+"); |
| 75 | m_nCountRequestNum = 0; | 76 | nCountRequestNum = 0; |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | if (fpMemChkPoint != NULL) { | 79 | if (fpMemChkPoint != NULL) { |
| @@ -101,10 +102,10 @@ void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAl · 22 unmodified lines | |||
| 101 | void WelsFree (void* pPointer, const char* kpTag) { | 102 | void WelsFree (void* pPointer, const char* kpTag) { |
| 102 | if (pPointer) { | 103 | if (pPointer) { |
| 103 | #ifdef MEMORY_CHECK | 104 | #ifdef MEMORY_CHECK |
| 104 | if (m_fpMemChkPoint != NULL) { | 105 | if (fpMemChkPoint != NULL) { |
| 105 | if (kpTag != NULL) | 106 | if (kpTag != NULL) |
| 106 | fprintf (fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag, | 107 | fprintf (fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag, |
| 107 | kiMemoryLength); | 108 | iMemoryLength); |
| 108 | else | 109 | else |
| 109 | fprintf (fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1))); | 110 | fprintf (fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1))); |
| 110 | fflush (fpMemChkPoint); | 111 | fflush (fpMemChkPoint); |
| @@ -129,9 +130,9 @@ void* CMemoryAlign::WelsMalloc (const uint32_t kuiSize, const char* kpTag) { · 18 unmodified lines | |||
| 129 | void* pPointer = WelsCommon::WelsMalloc (kuiSize, kpTag, m_nCacheLineSize); | 130 | void* pPointer = WelsCommon::WelsMalloc (kuiSize, kpTag, m_nCacheLineSize); |
| 130 | #ifdef MEMORY_MONITOR | 131 | #ifdef MEMORY_MONITOR |
| 131 | if (pPointer != NULL) { | 132 | if (pPointer != NULL) { |
| 132 | const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof ( | 133 | const int32_t iMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof ( |
| 133 | int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t); | 134 | int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t); |
| 134 | m_nMemoryUsageInBytes += kiMemoryLength; | 135 | m_nMemoryUsageInBytes += iMemoryLength; |
| 135 | } | 136 | } |
| 136 | #endif//MEMORY_MONITOR | 137 | #endif//MEMORY_MONITOR |
| 137 | return pPointer; | 138 | return pPointer; |
| @@ -140,9 +141,9 @@ void* CMemoryAlign::WelsMalloc (const uint32_t kuiSize, const char* kpTag) { · 2 unmodified lines | |||
| 140 | void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) { | 141 | void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) { |
| 141 | if (pPointer) { | 142 | if (pPointer) { |
| 142 | #ifdef MEMORY_MONITOR | 143 | #ifdef MEMORY_MONITOR |
| 143 | const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof ( | 144 | const int32_t iMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof ( |
| 144 | int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t); | 145 | int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t); |
| 145 | m_nMemoryUsageInBytes -= kiMemoryLength; | 146 | m_nMemoryUsageInBytes -= iMemoryLength; |
| 146 | #endif//MEMORY_MONITOR | 147 | #endif//MEMORY_MONITOR |
| 147 | } | 148 | } |
| 148 | WelsCommon::WelsFree (pPointer, kpTag); | 149 | WelsCommon::WelsFree (pPointer, kpTag); |