#include "ehs/PtrData.h" namespace ehs { Vector pointers; bool HasPtrData(void* data) { if (!data) return false; for (UInt_64 i = 0; i < pointers.Size(); i++) if (pointers[i].data == data) return true; return false; } void AddPtrData(void* data) { if (!data) return; for (UInt_64 i = 0; i < pointers.Size(); i++) { if (pointers[i].data != data) continue; pointers[i].references++; return; } pointers.Push({1, data}); } bool RemovePtrData(void* data) { if (!data) return false; for (UInt_64 i = 0; i < pointers.Size(); i++) { if (pointers[i].data != data) continue; if (pointers[i].references == 1) { pointers.Swap(i, pointers.End()); pointers.Pop(); return true; } else { pointers[i].references--; return false; } } return false; } }