/* Convert a text string of hexdecimal values into a byte string. */
void* parse_byte_string(char *bytes, u8 *data, size_t *count_ptr)
/* Convert a text string of hexdecimal values into a byte string. */
void* parse_byte_string(char *bytes, u8 *data, size_t *count_ptr)
{
	char byte[3];
	size_t count, length;
	int i;
	if (!bytes)
		return NULL;
	length = strlen(bytes);
	count = length / 2;
	if (!data)
		data = malloc(count);
	if (!data)
		return NULL;
	byte[2] = '\0';
	for (i = 0; i < length; i += 2) {
		byte[0] = bytes[i];
		byte[1] = bytes[i + 1];
		data[i / 2] = (u8)simple_strtoul(byte, NULL, 16);
	}
	if (count_ptr)
		*count_ptr = count;
	return data;
}