Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/hex/hex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ namespace arduino { namespace hex {
}

bool decode(const String in, uint8_t* out, uint32_t size) {
return decode(in.c_str(), out, size);
}

bool decode(const char *in, uint8_t* out, uint32_t size) {
unsigned int byteNumber;
byteNumber = chex_decode(out, size, in.begin(), in.length());
return byteNumber * 2 == in.length();
byteNumber = chex_decode(out, size, in, strlen(in));
return byteNumber * 2 == strlen(in);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
byteNumber = chex_decode(out, size, in, strlen(in));
return byteNumber * 2 == strlen(in);
size_t len = strlen(in);
byteNumber = chex_decode(out, size, in, len);
return byteNumber * 2 == len;

}

}} // arduino::hex
5 changes: 4 additions & 1 deletion src/hex/hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace arduino { namespace hex {

String encode(const uint8_t* in, uint32_t size);
String encodeUpper(const uint8_t* in, uint32_t size);

bool decode(const char *in, uint8_t* out, uint32_t size);
bool decode(const String in, uint8_t* out, uint32_t size);
}} // arduino::hex

Expand All @@ -37,4 +37,7 @@ class THEXT {
return arduino::hex::decode(in, out, size);
}

static inline bool decode(const char *in, uint8_t* out, uint32_t size) {
return arduino::hex::decode(in, out, size);
}
};
Loading