Skip to content

Commit

Permalink
Use positive checks for __GLIBC__ rather than ifndef
Browse files Browse the repository at this point in the history
  • Loading branch information
ksperling-apple committed May 28, 2024
1 parent debf71b commit e66fd0f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/platform/Linux/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,22 @@ DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance()

CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeapFree)
{
#ifndef __GLIBC__
return CHIP_ERROR_NOT_IMPLEMENTED;
#else
#if defined(__GLIBC__)
struct mallinfo mallocInfo = mallinfo();

// Get the current amount of heap memory, in bytes, that are not being utilized
// by the current running program.
currentHeapFree = mallocInfo.fordblks;

return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeapUsed)
{
#ifndef __GLIBC__
return CHIP_ERROR_NOT_IMPLEMENTED;
#else
#if defined(__GLIBC__)
struct mallinfo mallocInfo = mallinfo();

// Get the current amount of heap memory, in bytes, that are being used by
Expand All @@ -255,14 +253,14 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeap
maxHeapHighWatermark = currentHeapUsed;
}
return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark)
{
#ifndef __GLIBC__
return CHIP_ERROR_NOT_IMPLEMENTED;
#else
#if defined(__GLIBC__)
struct mallinfo mallocInfo = mallinfo();

// The usecase of this function is embedded devices,on which we would need to intercept
Expand All @@ -281,6 +279,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu
currentHeapHighWatermark = maxHeapHighWatermark;

return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

Expand Down

0 comments on commit e66fd0f

Please sign in to comment.