ref: bf44265c2ccc4f602b3cf65b0025e27ce13cc5ee
parent: 9ecc671fc334b1562f42c3cf706105b21c5ce7e2
parent: 71d0a7f71f2ef4a6e6c4ce158540c9c9e595c42c
author: sijchen <sijchen@cisco.com>
date: Wed Jun 17 13:34:57 EDT 2015
Merge pull request #1989 from sijchen/memc [Encoder] Amendments with MEMORY_CHECK on
--- a/codec/common/src/memory_align.cpp
+++ b/codec/common/src/memory_align.cpp
@@ -40,6 +40,7 @@
#ifdef MEMORY_CHECK
static FILE* fpMemChkPoint;
static uint32_t nCountRequestNum;
+static int32_t g_iMemoryLength;
#endif
@@ -71,8 +72,8 @@
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
#ifdef MEMORY_CHECK
if (fpMemChkPoint == NULL) {
- m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+");
- m_nCountRequestNum = 0;
+ fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+");
+ nCountRequestNum = 0;
}
if (fpMemChkPoint != NULL) {
@@ -101,10 +102,10 @@
void WelsFree (void* pPointer, const char* kpTag) {
if (pPointer) {
#ifdef MEMORY_CHECK
- if (m_fpMemChkPoint != NULL) {
+ if (fpMemChkPoint != NULL) {
if (kpTag != NULL)
fprintf (fpMemChkPoint, "WelsFree(), 0x%x - %s: \t%d\t bytes \n", (void*) (* (((void**) pPointer) - 1)), kpTag,
- kiMemoryLength);
+ g_iMemoryLength);
else
fprintf (fpMemChkPoint, "WelsFree(), 0x%x \n", (void*) (* (((void**) pPointer) - 1)));
fflush (fpMemChkPoint);
@@ -132,6 +133,9 @@
const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof (
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
m_nMemoryUsageInBytes += kiMemoryLength;
+#ifdef MEMORY_CHECK
+ g_iMemoryLength = kiMemoryLength;
+#endif
}
#endif//MEMORY_MONITOR
return pPointer;
@@ -138,13 +142,16 @@
}
void CMemoryAlign::WelsFree (void* pPointer, const char* kpTag) {
- if (pPointer) {
#ifdef MEMORY_MONITOR
+ if (pPointer) {
const int32_t kiMemoryLength = * ((int32_t*) ((uint8_t*)pPointer - sizeof (void**) - sizeof (
int32_t))) + m_nCacheLineSize - 1 + sizeof (void**) + sizeof (int32_t);
m_nMemoryUsageInBytes -= kiMemoryLength;
-#endif//MEMORY_MONITOR
+#ifdef MEMORY_CHECK
+ g_iMemoryLength = kiMemoryLength;
+#endif
}
+#endif//MEMORY_MONITOR
WelsCommon::WelsFree (pPointer, kpTag);
}