Skip to content

Commit 6e6a4af

Browse files
committed
Setup Ptr to print id when incrementing a delete pointer or decrementing to 0 an undeleted one.
1 parent 16e1ca8 commit 6e6a4af

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

source/base/Ptr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ namespace emp {
9292
void SetArray(size_t bytes) noexcept { array_bytes = bytes; status = PtrStatus::ARRAY; }
9393

9494
/// Add one more pointer.
95-
void Inc() {
95+
void Inc(size_t id) {
9696
if (ptr_debug) std::cout << "Inc info for pointer " << ptr << std::endl;
97-
emp_assert(status != PtrStatus::DELETED, "Incrementing deleted pointer!");
97+
emp_assert(status != PtrStatus::DELETED, "Incrementing deleted pointer!", id);
9898
count++;
9999
}
100100

101101
/// Remove a pointer.
102-
void Dec() {
102+
void Dec(size_t id) {
103103
if (ptr_debug) std::cout << "Dec info for pointer " << ptr << std::endl;
104104

105105
// Make sure that we have more than one copy, -or- we've already deleted this pointer
106-
emp_assert(count > 1 || status == PtrStatus::DELETED, "Removing last reference to owned Ptr!");
106+
emp_assert(count > 1 || status == PtrStatus::DELETED, "Removing last reference to owned Ptr!", id);
107107
count--;
108108
}
109109

@@ -243,7 +243,7 @@ namespace emp {
243243
void IncID(size_t id) {
244244
if (id == UNTRACKED_ID) return; // Not tracked!
245245
if (ptr_debug) std::cout << "Inc: " << id << std::endl;
246-
id_info[id].Inc();
246+
id_info[id].Inc(id);
247247
}
248248

249249
/// Decrement the nuber of Pointers associated with an ID
@@ -253,7 +253,7 @@ namespace emp {
253253
if (ptr_debug) std::cout << "Dec: " << id << "(" << info.GetPtr() << ")" << std::endl;
254254
emp_assert(info.GetCount() > 0, "Decrementing Ptr, but already zero!",
255255
id, info.GetPtr(), info.IsActive());
256-
info.Dec();
256+
info.Dec(id);
257257
}
258258

259259
/// Mark the pointers associated with this ID as deleted.

0 commit comments

Comments
 (0)