From 6d0372d0b35183ea30f03e3607f0267e3625aa5e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 8 Nov 2007 00:04:50 +0000 Subject: [PATCH] Revised implementation of BatchReadOwnedPtrs() that deserializes an array of pointers to not allocate a second array to contain the pointer ids. Fixed bug in the same member function where deserialized pointers were not being registered with the backpatcher. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43855 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bitcode/Deserialize.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index 5f8e1375593..48f78bf9e5d 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -168,17 +168,20 @@ public: } template - void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) { - llvm::SmallVector PtrIDs; - PtrIDs.reserve(NumPtrs); - - for (unsigned i = 0; i < NumPtrs; ++i) - PtrIDs.push_back(ReadInt()); - + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { for (unsigned i = 0; i < NumPtrs; ++i) - Ptrs[i] = PtrIDs[i] ? SerializeTrait::Materialize(*this) : NULL; - } - + reinterpret_cast(Ptrs[i]) = ReadInt(); + + for (unsigned i = 0; i < NumPtrs; ++i) { + unsigned PtrID = reinterpret_cast(Ptrs[i]); + T* p = PtrID ? SerializeTrait::Materialize(*this) : NULL; + + if (PtrID && AutoRegister) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + } template void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) { -- 2.34.1