aboutsummaryrefslogtreecommitdiff
path: root/tests/hex.h
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-04-03 18:10:08 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-04-03 18:10:08 -0400
commitb11bc0bac955fd5c6db65f0da48456bf5e748805 (patch)
tree5af4a40a27bbf210e7c813010a54a6befcee0788 /tests/hex.h
parent9915bd41799a72413e6b400e150aa9f5fa797e25 (diff)
fix: Fix c89 compatabilty comments and struct assignment
Diffstat (limited to 'tests/hex.h')
-rw-r--r--tests/hex.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/hex.h b/tests/hex.h
index 793e9f9..7c8080a 100644
--- a/tests/hex.h
+++ b/tests/hex.h
@@ -56,9 +56,11 @@ static size_t _hdeferListIndex = 0;
static HexBytes* __allocHexBytes(size_t length)
{
+ HexBytes* hexBytes;
+
length /= 2;
- HexBytes* hexBytes = (HexBytes*)malloc(length + sizeof(HexBytes));
+ hexBytes = (HexBytes*)malloc(length + sizeof(HexBytes));
if(!hexBytes)
{
return NULL;
@@ -89,7 +91,11 @@ static HexBytes* _fromHexString(const char* hexLiteral, size_t strLen)
for (i = 0; i < strLen; i += 2)
{
/* slice string into smaller 2 char strings then parse */
- char byteString[3] = { hexLiteral[i], hexLiteral[i + 1], '\0'};
+ char byteString[3] = { '\0' };
+
+ byteString[0] = hexLiteral[i];
+ byteString[1] = hexLiteral[i + 1];
+
hexBytes->data[i / 2] = (uint8_t)strtol(byteString, NULL, 16);
}
@@ -143,6 +149,6 @@ static void PrintHexBytes(HexBytes* hexBytes)
}
-#endif // !HEX_HELPERS_H
+#endif /* !HEX_HELPERS_H */