llvm.org GIT mirror llvm / 6d0372d
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 Ted Kremenek 12 years ago
1 changed file(s) with 13 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
167167 }
168168
169169 template
170 void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
171 llvm::SmallVector PtrIDs;
172 PtrIDs.reserve(NumPtrs);
173
170 void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) {
174171 for (unsigned i = 0; i < NumPtrs; ++i)
175 PtrIDs.push_back(ReadInt());
176
177 for (unsigned i = 0; i < NumPtrs; ++i)
178 Ptrs[i] = PtrIDs[i] ? SerializeTrait::Materialize(*this) : NULL;
179 }
180
172 reinterpret_cast(Ptrs[i]) = ReadInt();
173
174 for (unsigned i = 0; i < NumPtrs; ++i) {
175 unsigned PtrID = reinterpret_cast(Ptrs[i]);
176 T* p = PtrID ? SerializeTrait::Materialize(*this) : NULL;
177
178 if (PtrID && AutoRegister)
179 RegisterPtr(PtrID,p);
180
181 Ptrs[i] = p;
182 }
183 }
181184
182185 template
183186 void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {