From 44e99bce3dbf508df27a4a36034b96a5eced55bc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 13 Sep 2015 12:06:38 +0200 Subject: [PATCH] Core/HashDigest: Cleanup code Former-commit-id: 869c880df6822e7cccf4b847bbba9a5390100a5d --- src/Nazara/Core/HashDigest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Core/HashDigest.cpp b/src/Nazara/Core/HashDigest.cpp index a66feeb84..4299d7b22 100644 --- a/src/Nazara/Core/HashDigest.cpp +++ b/src/Nazara/Core/HashDigest.cpp @@ -82,11 +82,12 @@ NzString NzHashDigest::ToHex() const return NzString(); unsigned int length = m_digestLength*2; - char* hexOutput = new char[length+1]; - for (unsigned int i = 0; i < m_digestLength; ++i) - std::sprintf(hexOutput + i*2, "%02x", m_digest[i]); - return NzString(new NzString::SharedString(1, length, length, hexOutput)); + NzString hexOutput(length); + for (unsigned int i = 0; i < m_digestLength; ++i) + std::sprintf(&hexOutput[i*2], "%02x", m_digest[i]); + + return hexOutput; } nzUInt8 NzHashDigest::operator[](unsigned int pos) const