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.

llvm-svn: 43855
This commit is contained in:
Ted Kremenek 2007-11-08 00:04:50 +00:00
parent 766fc8c14a
commit 8f74abd34a
1 changed files with 12 additions and 9 deletions

View File

@ -168,17 +168,20 @@ public:
}
template <typename T>
void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
llvm::SmallVector<unsigned,20> PtrIDs;
PtrIDs.reserve(NumPtrs);
void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) {
for (unsigned i = 0; i < NumPtrs; ++i)
PtrIDs.push_back(ReadInt());
reinterpret_cast<uintptr_t&>(Ptrs[i]) = ReadInt();
for (unsigned i = 0; i < NumPtrs; ++i)
Ptrs[i] = PtrIDs[i] ? SerializeTrait<T>::Materialize(*this) : NULL;
for (unsigned i = 0; i < NumPtrs; ++i) {
unsigned PtrID = reinterpret_cast<uintptr_t>(Ptrs[i]);
T* p = PtrID ? SerializeTrait<T>::Materialize(*this) : NULL;
if (PtrID && AutoRegister)
RegisterPtr(PtrID,p);
Ptrs[i] = p;
}
}
template <typename T>
void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {