[libc-commits] [libc] [libc] Use RAII based alloc in gpu rpc_server instead of manual new/delete (PR #110341)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Sep 27 18:52:18 PDT 2024


================
@@ -206,6 +206,18 @@ void handle_printf(rpc::Server::Port &port) {
     delete[] reinterpret_cast<char *>(ptr);
 }
 
+namespace {
+struct TempStorage {
+  char *alloc(size_t size) {
+    storage.emplace_back(std::make_unique<char[]>(size));
+    return storage.back().get();
+  }
+
+  // TODO: SmallVector
----------------
jhuber6 wrote:

If this were LLVM we could probably just use a bump pointer, but this is good enough.

https://github.com/llvm/llvm-project/pull/110341


More information about the libc-commits mailing list