diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:36:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:36:29 +0000 |
commit | 00919f57697fda4997986cc5e43e80ca573dbc87 (patch) | |
tree | 34aa826213a02e4c70c3e685a28419ce4e015511 | |
parent | c3bfe13ed5d0bcd25e3db815b8f4576f137e1f92 (diff) | |
download | bcm5719-llvm-00919f57697fda4997986cc5e43e80ca573dbc87.tar.gz bcm5719-llvm-00919f57697fda4997986cc5e43e80ca573dbc87.zip |
Avoid memory leakage by having caller construct the APInt for the
destination value of LoadValueFromMemory.
llvm-svn: 34883
-rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index 55793219bcf..ca077fcef05 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -578,9 +578,9 @@ Store4BytesLittleEndian: /// 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 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((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 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((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 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, abort(); } } - return Result; } // InitializeMemory - Recursive function to apply a Constant value into the |