Skip to content

Commit

Permalink
Fix memory leak in RefCounted, hashmap errors
Browse files Browse the repository at this point in the history
  • Loading branch information
etcimon committed Dec 17, 2023
1 parent 9f02938 commit 414a767
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.dub
*.exe
*.lib
*.pdb
*.pdb
*.a
*-unittest
2 changes: 1 addition & 1 deletion source/memutils/debugger.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version(LogAllocations) static if (HasDebugAllocations) {

static __gshared FileLogger sharedLog;
static this() {
sharedLog = new FileLogger("allocations.log", LogLevel.trace);
sharedLog = new FileLogger("../allocations.log", LogLevel.trace);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/memutils/hashmap.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct HashMap(Key, Value, ALLOC = ThreadMem)
auto idx = this.findIndex(key);
if (idx == size_t.max) return default_value;
const Value ret = m_table[idx].value;
return cast()ret;
return cast(Value)ret;
}
/*
static if (!is(typeof({ Value v; const(Value) vc; v = vc; }))) {
Expand Down
4 changes: 1 addition & 3 deletions source/memutils/refcounted.d
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ struct RefCounted(T, ALLOC = ThreadMem)
if (!m_object) {
defaultInit();
checkInvariants();
}

if (m_object) (*m_refCount)++;
} else (*m_refCount)++;
}

void opAssign(U : RefCounted)(in U other) const nothrow
Expand Down

0 comments on commit 414a767

Please sign in to comment.