aboutsummaryrefslogtreecommitdiffstats
path: root/util/string/hex.cpp
diff options
context:
space:
mode:
authordobrokot <dobrokot@yandex-team.ru>2022-02-10 16:49:07 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:07 +0300
commit8d57b69dee81198a59c39e64704f7dc9f04b4fbf (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/string/hex.cpp
parent25d83bf841d8b3ce3886525078f1964ac3c293c5 (diff)
downloadydb-8d57b69dee81198a59c39e64704f7dc9f04b4fbf.tar.gz
Restoring authorship annotation for <dobrokot@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/string/hex.cpp')
-rw-r--r--util/string/hex.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/util/string/hex.cpp b/util/string/hex.cpp
index deea4e3ba7..667397987f 100644
--- a/util/string/hex.cpp
+++ b/util/string/hex.cpp
@@ -1,5 +1,5 @@
-#include "hex.h"
-
+#include "hex.h"
+
const char* const Char2DigitTable = ("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
@@ -16,48 +16,48 @@ const char* const Char2DigitTable = ("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
-
-char* HexEncode(const void* in, size_t len, char* out) {
- const unsigned char* b = (const unsigned char*)in;
- const unsigned char* e = b + len;
-
- while (b != e) {
- *out++ = DigitToChar(*b / 16);
- *out++ = DigitToChar(*b++ % 16);
- }
-
- return out;
-}
-
-void* HexDecode(const void* in, size_t len, void* ptr) {
- const char* b = (const char*)in;
- const char* e = b + len;
+
+char* HexEncode(const void* in, size_t len, char* out) {
+ const unsigned char* b = (const unsigned char*)in;
+ const unsigned char* e = b + len;
+
+ while (b != e) {
+ *out++ = DigitToChar(*b / 16);
+ *out++ = DigitToChar(*b++ % 16);
+ }
+
+ return out;
+}
+
+void* HexDecode(const void* in, size_t len, void* ptr) {
+ const char* b = (const char*)in;
+ const char* e = b + len;
Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode"));
-
- char* out = (char*)ptr;
-
- while (b != e) {
+
+ char* out = (char*)ptr;
+
+ while (b != e) {
*out++ = (char)String2Byte(b);
- b += 2;
- }
-
- return out;
-}
-
+ b += 2;
+ }
+
+ return out;
+}
+
TString HexEncode(const void* in, size_t len) {
TString ret;
-
- ret.ReserveAndResize(len << 1);
- HexEncode(in, len, ret.begin());
-
- return ret;
-}
-
+
+ ret.ReserveAndResize(len << 1);
+ HexEncode(in, len, ret.begin());
+
+ return ret;
+}
+
TString HexDecode(const void* in, size_t len) {
TString ret;
-
+
ret.ReserveAndResize(len >> 1);
HexDecode(in, len, ret.begin());
-
- return ret;
-}
+
+ return ret;
+}