0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::allocator: Add trim() if available.

This commit is contained in:
Jason Volk 2018-06-09 13:31:54 -07:00
parent 7dd23cd4f0
commit 55a8391e48
2 changed files with 18 additions and 0 deletions

View file

@ -24,6 +24,8 @@ namespace ircd::allocator
template<class T = char> struct dynamic;
template<class T = char, size_t = 512> struct fixed;
template<class T> struct node;
bool trim(const size_t &pad = 0); // malloc_trim(3)
};
/// Profiling counters.

View file

@ -8,6 +8,8 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#include <RB_INC_MALLOC_H
// Uncomment or -D this #define to enable our own crude but simple ability to
// profile dynamic memory usage. Global `new` and `delete` will be captured
// here by this definition file into thread_local counters accessible via
@ -16,6 +18,20 @@
//
// #define RB_PROF_ALLOC
#if defined(__GNU_LIBRARY__) && defined(HAVE_MALLOC_H)
bool
ircd::allocator::trim(const size_t &pad)
{
return malloc_trim(pad);
}
#else
bool
ircd::allocator::trim(const size_t &pad)
{
return false;
}
#endif
//
// allocator::state
//