blob: 71da441c1f9bdd6f746c4930e578e986992406f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include <cstddef>
class AllocationIndex {
public:
AllocationIndex() = delete;
/**
* @brief Starts/stops allocated memory indexing.
*/
static void setActive(bool);
/**
* @brief Returns memory indexing activity status.
*/
static bool isActive();
/**
* @brief Resets the allocated memory index and all statistics data.
*/
static void reset();
/**
* @brief Same as `malloc()` + indexes the allocated data,
* if indexing is active.
*
* @return void*
*/
static void* allocate(size_t);
/**
* @brief Same as `free()` + removes the corresponding data from index,
* if these data are present in the index and indexing is active.
*
* @return void*
*/
static void deallocate(void*) noexcept;
/**
* @brief Returns the size (in bytes) of allocated data, currently present in the index.
*
* @return size_t
*/
static size_t getAllocatedSize();
/**
* @brief Returns the total amount of allocations since indexing start.
*
* @return size_t
*/
static size_t getAllocationsCount();
/**
* @brief Returns the maximum size (in bytes) of the allocated data in the index, since last `reset()` call.
*
* @return size_t
*/
static size_t getAllocatedSizePeak();
};
|