CoroutineLeakCheck
This commit is contained in:
@@ -47,6 +47,7 @@ struct BlockArena {
|
||||
U8 *end;
|
||||
BlockArenaNode *blocks;
|
||||
Allocator allocator;
|
||||
int refs; // :CoroutineLeakCheck
|
||||
|
||||
operator Allocator() { return {BlockArenaAllocatorProc, this}; }
|
||||
};
|
||||
@@ -66,6 +67,7 @@ struct VirtualArena {
|
||||
size_t reserve;
|
||||
size_t commit;
|
||||
size_t align;
|
||||
int refs; // :CoroutineLeakCheck
|
||||
|
||||
operator Allocator() {
|
||||
void *ArenaAllocatorProc(void *object, int kind, void *p, size_t size);
|
||||
@@ -112,28 +114,32 @@ API VirtualArena *GetScratchEx(VirtualArena **conflicts, int conflict_count);
|
||||
struct Scratch {
|
||||
VirtualArena *arena;
|
||||
U64 p;
|
||||
Scratch() {arena = &ScratchArenas[0]; p = arena->len;}
|
||||
Scratch() {arena = &ScratchArenas[0]; p = arena->len; arena->refs += 1;}
|
||||
Scratch(VirtualArena *conflict) {
|
||||
VirtualArena *conf[] = {conflict};
|
||||
arena = GetScratchEx(conf, Lengthof(conf));
|
||||
p = arena->len;
|
||||
arena->refs += 1;
|
||||
}
|
||||
Scratch(VirtualArena *c1, VirtualArena *c2) {
|
||||
VirtualArena *conf[] = {c1, c2};
|
||||
arena = GetScratchEx(conf, Lengthof(conf));
|
||||
p = arena->len;
|
||||
arena->refs += 1;
|
||||
}
|
||||
Scratch(Allocator conflict) {
|
||||
VirtualArena *conf[] = {(VirtualArena *)conflict.object};
|
||||
arena = GetScratchEx(conf, Lengthof(conf));
|
||||
p = arena->len;
|
||||
arena->refs += 1;
|
||||
}
|
||||
Scratch(Allocator c1, Allocator c2) {
|
||||
VirtualArena *conf[] = {(VirtualArena *)c1.object, (VirtualArena *)c2.object};
|
||||
arena = GetScratchEx(conf, Lengthof(conf));
|
||||
p = arena->len;
|
||||
arena->refs += 1;
|
||||
}
|
||||
~Scratch() { SetLen(arena, p); }
|
||||
~Scratch() { SetLen(arena, p); arena->refs -= 1; }
|
||||
operator VirtualArena *() { return arena; }
|
||||
operator Allocator() { return *arena; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user