feat(list): tag allocations with file name and line

This commit is contained in:
fallenoak 2021-01-06 22:38:43 -06:00
parent 577fb30be0
commit 8ed2e9a9bf
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D

View file

@ -6,6 +6,7 @@
#include "storm/list/TSLink.hpp"
#include <cstddef>
#include <cstdint>
#include <typeinfo>
#define STORM_LIST(T) TSList<T, TSGetLink<T>>
@ -29,6 +30,8 @@ class TSList {
void LinkNode(T* ptr, uint32_t linktype, T* existingptr);
void LinkToHead(T* ptr);
void LinkToTail(T* ptr);
const char* MemFileName() const;
int32_t MemLineNo() const;
T* NewNode(uint32_t location, size_t extrabytes, uint32_t flags);
T* Next(const T* ptr);
T* RawNext(const T* ptr);
@ -156,9 +159,19 @@ void TSList<T, TGetLink>::LinkToTail(T* ptr) {
this->LinkNode(ptr, 2, nullptr);
}
template <class T, class TGetLink>
const char* TSList<T, TGetLink>::MemFileName() const {
return typeid(T).name();
}
template <class T, class TGetLink>
int32_t TSList<T, TGetLink>::MemLineNo() const {
return -2;
}
template <class T, class TGetLink>
T* TSList<T, TGetLink>::NewNode(uint32_t location, size_t extrabytes, uint32_t flags) {
void* m = SMemAlloc(sizeof(T) + extrabytes, __FILE__, __LINE__, flags);
void* m = SMemAlloc(sizeof(T) + extrabytes, this->MemFileName(), this->MemLineNo(), flags);
T* node;