resonance 1.0.1
Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1#pragma once
2
3#include <stddef.h>
4#include <stdio.h>
5
6#ifdef __cplusplus
13constexpr int kMemTagCount = 24;
14
16constexpr int kMemTagNameSize = 124;
17
25struct MemTagTotal {
26 char mName[kMemTagNameSize];
27 int mBytes;
28};
29
31constexpr int kMemStlTagSize = 128;
32#endif
33
34#ifdef __cplusplus
47void *operator new[](size_t nSize);
48
63void *operator new(size_t nSize);
64#endif
65
84void *AllocateTaggedMemory(size_t nSize, const char *pszClass);
85
97void OperatorDeleteOverride(void *pBlock, const char *pszClass);
98
111
124void MemSetStlTag(const char *pszKind, int nElemSize);
125
140#ifdef __cplusplus
141extern "C" {
142#endif
143void *MemAllocTagged(size_t nSize, const char *pszTag, int nLine);
144#ifdef __cplusplus
145}
146#endif
147
148#ifdef __cplusplus
159void operator delete[](void *pBlock) noexcept;
160
172void operator delete(void *pBlock) noexcept;
173#endif
174
187#ifdef __cplusplus
188extern "C" {
189#endif
190void MemFreeTagged(void *pBlock, const char *pszTag, int nLine);
191#ifdef __cplusplus
192}
193#endif
194
207int MemLogFindSource(const char *pszName);
208
223void *MemReallocTagged(void *pBlock, size_t nSize, const char *pszTag, int nLine);
224
234void MemLogWriteMarker(const char *pszText);
235
248
263void MemOpenLog(const char *pszPath);
264
277
287void MemLogPrint(const char *pszText);
288
299
313int MemLogEndCount(char *pszReport, int nReportSize);
314
325
340void MemLogSourceTrackRealloc(const char *pszSource, void *pNew, void *pOld, int nSize);
341
353void MemLogSourceReport(const char *pszTitle, FILE *pFile);
354
367void DumpHeapMemoryLog(int nIndex);
368
381#ifdef __cplusplus
382extern "C" {
383#endif
384void *HeapAlloc(size_t nSize);
385#ifdef __cplusplus
386}
387#endif
388
399#ifdef __cplusplus
400extern "C" {
401#endif
402void HeapFree(void *pBlock);
403#ifdef __cplusplus
404}
405#endif
406
419#ifdef __cplusplus
420extern "C" {
421#endif
422void *HeapRealloc(void *pBlock, size_t nSize);
423#ifdef __cplusplus
424}
425#endif
426
void MemLogSourceReport(const char *pszTitle, FILE *pFile)
Print the per-source table, sorted by name.
void ReportHeapCapacity()
Log how much of the backing allocator is free, then give it all back.
void MemSetStlTag(const char *pszKind, int nElemSize)
Bill the next STL allocation to a container kind and element size.
void MemLogWriteMarker(const char *pszText)
Write a marker line into the memory report.
int MemLogEndCount(char *pszReport, int nReportSize)
Stop charging the accounting table and format its totals.
void MemLogPrint(const char *pszText)
Write text to the memory report while logging is on.
void HeapFree(void *pBlock)
Give a block back to the backing allocator.
void MemFreeTagged(void *pBlock, const char *pszTag, int nLine)
Release a block and record the release against a tag.
void OperatorDeleteOverride(void *pBlock, const char *pszClass)
Release a block that AllocateTaggedMemory() handed out.
void * HeapAlloc(size_t nSize)
Take a block from the backing allocator.
int MemLogFindSource(const char *pszName)
Find or claim the report row for a source name.
void MemLogBeginCount()
Clear the per-tag accounting table and start charging it.
void MemLogCloseAndContinue()
Start a new report file that retains everything written so far.
void MemLogSourceTrackRealloc(const char *pszSource, void *pNew, void *pOld, int nSize)
Move a tracked block to its new address after a resize.
void * MemAllocTagged(size_t nSize, const char *pszTag, int nLine)
Allocate a block and record the request against a tag.
void MemOpenLog(const char *pszPath)
Open the memory report and paint the stack.
void * HeapRealloc(void *pBlock, size_t nSize)
Resize a block through the backing allocator.
void MemLogSourceInit()
Allocate the per-block tracking table and clear the per-source table.
void MemCloseLogAndReport()
Close the memory report and print a summary of the heap.
void DumpHeapMemoryLog(int nIndex)
Write the memory statistics files and probe the largest possible allocation.
char * MemGetCurrentTag()
Address the buffer the STL allocator hook bills its allocations to.
void * AllocateTaggedMemory(size_t nSize, const char *pszClass)
Allocate a block for one object of a named class.
void * MemReallocTagged(void *pBlock, size_t nSize, const char *pszTag, int nLine)
Resize a block and record the move against a tag.