]> git.lizzy.rs Git - minetest.git/blobdiff - src/util/hex.h
Fix BSD iconv declaration
[minetest.git] / src / util / hex.h
index c205d01da3f8e443f307b9e1d02a6b03f33ed7ba..708f330242fb4a21b40d6b19ec51b76ad6b91979 100644 (file)
@@ -17,8 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef HEX_HEADER
-#define HEX_HEADER
+#pragma once
 
 #include <string>
 
@@ -27,6 +26,8 @@ static const char hex_chars[] = "0123456789abcdef";
 static inline std::string hex_encode(const char *data, unsigned int data_size)
 {
        std::string ret;
+       ret.reserve(data_size * 2);
+
        char buf2[3];
        buf2[2] = '\0';
 
@@ -57,5 +58,3 @@ static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
                return false;
        return true;
 }
-
-#endif