mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #7444 from miyazakh/trackmem_exclusion
Exclusively tracking mem propertiespull/7460/head
commit
c3d9fb61a8
|
@ -177,6 +177,10 @@ static WC_INLINE void* TrackMalloc(size_t sz)
|
|||
(void)line;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||
if (pthread_mutex_lock(&memLock) == 0)
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef DO_MEM_STATS
|
||||
ourMemStats.totalAllocs++;
|
||||
|
@ -197,10 +201,10 @@ static WC_INLINE void* TrackMalloc(size_t sz)
|
|||
if (ourMemStats.currentBytes > ourMemStats.peakBytes)
|
||||
ourMemStats.peakBytes = ourMemStats.currentBytes;
|
||||
}
|
||||
|
||||
#endif /* DO_MEM_STATS */
|
||||
|
||||
#ifdef DO_MEM_LIST
|
||||
if (pthread_mutex_lock(&memLock) == 0) {
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
header->func = func;
|
||||
header->line = line;
|
||||
|
@ -218,7 +222,8 @@ static WC_INLINE void* TrackMalloc(size_t sz)
|
|||
}
|
||||
ourMemList.tail = header; /* add to the end either way */
|
||||
ourMemList.count++;
|
||||
|
||||
#endif
|
||||
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||
pthread_mutex_unlock(&memLock);
|
||||
}
|
||||
#endif /* DO_MEM_LIST */
|
||||
|
@ -245,7 +250,7 @@ static WC_INLINE void TrackFree(void* ptr)
|
|||
header = &mt->u.hint;
|
||||
sz = header->thisSize;
|
||||
|
||||
#ifdef DO_MEM_LIST
|
||||
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||
if (pthread_mutex_lock(&memLock) == 0)
|
||||
{
|
||||
#endif
|
||||
|
@ -277,7 +282,9 @@ static WC_INLINE void TrackFree(void* ptr)
|
|||
prev->next = next;
|
||||
}
|
||||
ourMemList.count--;
|
||||
#endif
|
||||
|
||||
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||
pthread_mutex_unlock(&memLock);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue