From: svost Date: Tue, 13 Sep 2016 08:05:37 +0000 (+0300) Subject: Drop sprintf dependency X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=b647f57075aa526910e045afc5c9c511cefe5df7 Drop sprintf dependency --- diff --git a/src/uint256.h b/src/uint256.h index 114ef89..526aa71 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -6,10 +6,10 @@ #define BITCOIN_UINT256_H #include -#include #include #include -#include +#include +#include using namespace std; @@ -297,10 +297,11 @@ public: std::string GetHex() const { - char psz[sizeof(pn)*2 + 1]; - for (unsigned int i = 0; i < sizeof(pn); i++) - sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]); - return std::string(psz, psz + sizeof(pn)*2); + std::stringstream ss; + size_t pn_size = sizeof(pn) / sizeof(pn[0]); + for (size_t i = 1; i <= pn_size; i++) + ss << std::setfill('0') << std::setw(8) << std::setbase(16) << pn[pn_size-i]; + return ss.str(); } void SetHex(const char* psz)