mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Merge pull request #7444 from miyazakh/trackmem_exclusion
Exclusively tracking mem properties
This commit is contained in:
@ -177,30 +177,34 @@ static WC_INLINE void* TrackMalloc(size_t sz)
|
|||||||
(void)line;
|
(void)line;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||||
|
if (pthread_mutex_lock(&memLock) == 0)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DO_MEM_STATS
|
#ifdef DO_MEM_STATS
|
||||||
ourMemStats.totalAllocs++;
|
ourMemStats.totalAllocs++;
|
||||||
ourMemStats.totalBytes += sz;
|
ourMemStats.totalBytes += sz;
|
||||||
ourMemStats.currentBytes += sz;
|
ourMemStats.currentBytes += sz;
|
||||||
#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE
|
|
||||||
if (ourMemStats.peakAllocsTripOdometer < ourMemStats.totalAllocs -
|
|
||||||
ourMemStats.totalDeallocs) {
|
|
||||||
ourMemStats.peakAllocsTripOdometer = ourMemStats.totalAllocs -
|
|
||||||
ourMemStats.totalDeallocs;
|
|
||||||
}
|
|
||||||
if (ourMemStats.peakBytesTripOdometer < ourMemStats.currentBytes)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE
|
#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE
|
||||||
ourMemStats.peakBytesTripOdometer = ourMemStats.currentBytes;
|
if (ourMemStats.peakAllocsTripOdometer < ourMemStats.totalAllocs -
|
||||||
|
ourMemStats.totalDeallocs) {
|
||||||
|
ourMemStats.peakAllocsTripOdometer = ourMemStats.totalAllocs -
|
||||||
|
ourMemStats.totalDeallocs;
|
||||||
|
}
|
||||||
|
if (ourMemStats.peakBytesTripOdometer < ourMemStats.currentBytes)
|
||||||
#endif
|
#endif
|
||||||
if (ourMemStats.currentBytes > ourMemStats.peakBytes)
|
{
|
||||||
ourMemStats.peakBytes = ourMemStats.currentBytes;
|
#ifdef WOLFSSL_TRACK_MEMORY_VERBOSE
|
||||||
}
|
ourMemStats.peakBytesTripOdometer = ourMemStats.currentBytes;
|
||||||
|
#endif
|
||||||
|
if (ourMemStats.currentBytes > ourMemStats.peakBytes)
|
||||||
|
ourMemStats.peakBytes = ourMemStats.currentBytes;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DO_MEM_STATS */
|
#endif /* DO_MEM_STATS */
|
||||||
|
|
||||||
#ifdef DO_MEM_LIST
|
#ifdef DO_MEM_LIST
|
||||||
if (pthread_mutex_lock(&memLock) == 0) {
|
|
||||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||||
header->func = func;
|
header->func = func;
|
||||||
header->line = line;
|
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.tail = header; /* add to the end either way */
|
||||||
ourMemList.count++;
|
ourMemList.count++;
|
||||||
|
#endif
|
||||||
|
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||||
pthread_mutex_unlock(&memLock);
|
pthread_mutex_unlock(&memLock);
|
||||||
}
|
}
|
||||||
#endif /* DO_MEM_LIST */
|
#endif /* DO_MEM_LIST */
|
||||||
@ -245,7 +250,7 @@ static WC_INLINE void TrackFree(void* ptr)
|
|||||||
header = &mt->u.hint;
|
header = &mt->u.hint;
|
||||||
sz = header->thisSize;
|
sz = header->thisSize;
|
||||||
|
|
||||||
#ifdef DO_MEM_LIST
|
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||||
if (pthread_mutex_lock(&memLock) == 0)
|
if (pthread_mutex_lock(&memLock) == 0)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
@ -277,7 +282,9 @@ static WC_INLINE void TrackFree(void* ptr)
|
|||||||
prev->next = next;
|
prev->next = next;
|
||||||
}
|
}
|
||||||
ourMemList.count--;
|
ourMemList.count--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(DO_MEM_LIST) || defined(DO_MEM_STATS)
|
||||||
pthread_mutex_unlock(&memLock);
|
pthread_mutex_unlock(&memLock);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user