From b11bc0bac955fd5c6db65f0da48456bf5e748805 Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 3 Apr 2024 18:10:08 -0400 Subject: fix: Fix c89 compatabilty comments and struct assignment --- tests/hex.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/hex.h') 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 */ -- cgit