[compiler-rt] [scudo] Use MemMap in BufferPool and RegionPageMap (PR #66788)

Fabio D'Urso via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 07:34:11 PDT 2023


================
@@ -130,53 +143,33 @@ class BufferPool {
     if (index >= StaticBufferCount)
       return getDynamicBuffer(NumElements);
 
-    const uptr Offset = index * StaticBufferNumElements;
-    memset(&RawBuffer[Offset], 0, StaticBufferNumElements * sizeof(uptr));
-    return &RawBuffer[Offset];
+    Buffer Buf;
+    Buf.Data = &RawBuffer[index * StaticBufferNumElements];
+    Buf.BufferIndex = index;
+    memset(Buf.Data, 0, StaticBufferNumElements * sizeof(uptr));
+    return Buf;
   }
 
-  void releaseBuffer(uptr *Buffer, const uptr NumElements) {
-    const uptr index = getStaticBufferIndex(Buffer, NumElements);
-    if (index < StaticBufferCount) {
+  void releaseBuffer(Buffer Buf) {
+    DCHECK(Buf.Data != nullptr);
----------------
fabio-d wrote:

Done, thanks!

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


More information about the llvm-commits mailing list