diff --git a/app/src/main/cpp/skyline/common/linear_allocator.h b/app/src/main/cpp/skyline/common/linear_allocator.h index 719321de..56ec7929 100644 --- a/app/src/main/cpp/skyline/common/linear_allocator.h +++ b/app/src/main/cpp/skyline/common/linear_allocator.h @@ -29,7 +29,7 @@ namespace skyline { /** * @brief Allocates a contiguous chunk of memory of size `size` aligned to the maximum possible required alignment */ - u8 *Allocate(size_t unalignedSize) { + u8 *Allocate(size_t unalignedSize, bool track = true) { // Align the size to the maximum required alignment for standard types size_t size{util::AlignUp(unalignedSize, alignof(std::max_align_t))}; @@ -51,11 +51,22 @@ namespace skyline { chunkRemainingBytes -= size; ptr += size; - allocCount++; + if (track) + allocCount++; return allocatedPtr; } + template + T *AllocateUntracked() { + return reinterpret_cast(Allocate(sizeof(T), false)); + } + + template + T *EmplaceUntracked(Args &&... args) { + return std::construct_at(AllocateUntracked(), std::forward(args)...); + } + /** * @brief Decreases allocation count, should be called an equal number of times to `Allocate` */