[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Reid Spencer
reid at x10sys.com
Sat Mar 3 00:36:46 PST 2007
Changes in directory llvm/lib/ExecutionEngine:
ExecutionEngine.cpp updated: 1.108 -> 1.109
---
Log message:
Avoid memory leakage by having caller construct the APInt for the
destination value of LoadValueFromMemory.
---
Diffs of the changes: (+4 -5)
ExecutionEngine.cpp | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.108 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.109
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.108 Sat Mar 3 00:18:03 2007
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Sat Mar 3 02:36:29 2007
@@ -578,9 +578,9 @@
/// FIXME: document
///
-GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
+void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
+ GenericValue *Ptr,
const Type *Ty) {
- GenericValue Result;
if (getTargetData()->isLittleEndian()) {
switch (Ty->getTypeID()) {
case Type::IntegerTyID: {
@@ -605,7 +605,7 @@
((uint64_t)Ptr->Untyped[6] << 48) |
((uint64_t)Ptr->Untyped[7] << 56);
} else
- Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
+ *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
break;
}
Load4BytesLittleEndian:
@@ -657,7 +657,7 @@
((uint64_t)Ptr->Untyped[1] << 48) |
((uint64_t)Ptr->Untyped[0] << 56);
} else
- Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
+ *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
break;
}
Load4BytesBigEndian:
@@ -686,7 +686,6 @@
abort();
}
}
- return Result;
}
// InitializeMemory - Recursive function to apply a Constant value into the
More information about the llvm-commits
mailing list