[flang-commits] [flang] [flang][runtime] Interoperable POINTER deallocation validation (PR #96100)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Tue Jun 25 08:26:45 PDT 2024


================
@@ -124,6 +124,23 @@ void RTDEF(PointerAssociateRemapping)(Descriptor &pointer,
   }
 }
 
+RT_API_ATTRS void *AllocateValidatedPointerPayload(std::size_t byteSize) {
+  // Add space for a footer to validate during deallocation.
+  constexpr std::size_t align{sizeof(std::uintptr_t)};
+  byteSize = ((byteSize / align) + 1) * align;
----------------
vzakhari wrote:

Yes, `byteSize` is equal to `align`, and then `total` (below) is equal to `align + sizeof(std::uintptr_t)` - this is how much memory is being malloc'ed.  I am asking why we need to malloc more than `align` bytes of memory.

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


More information about the flang-commits mailing list