automerge/rust/automerge-c/test/str_utils.c
Alex Good dd3c6d1303
Move rust workspace into ./rust
After some discussion with PVH I realise that the repo structure in the
last reorg was very rust-centric. In an attempt to put each language on
a level footing move the rust code and project files into ./rust
2022-10-16 19:55:51 +01:00

15 lines
386 B
C

#include <stdio.h>
#include <stdint.h>
/* local */
#include "str_utils.h"
void hex_to_bytes(char const* hex_str, uint8_t* src, size_t const count) {
unsigned int byte;
char const* next = hex_str;
for (size_t index = 0; *next && index != count; next += 2, ++index) {
if (sscanf(next, "%02x", &byte) == 1) {
src[index] = (uint8_t)byte;
}
}
}