From 0ec218656a02ea48e173262f7b80513feeb7f263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Tue, 31 Oct 2017 14:46:49 +0100 Subject: notes: move hex_to_bytes() to hex.c and export it Make the function for converting pairs of hexadecimal digits to binary available to other call sites. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- cache.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 6440e2bf2..f06bfbaf3 100644 --- a/cache.h +++ b/cache.h @@ -1317,6 +1317,13 @@ extern int set_disambiguate_hint_config(const char *var, const char *value); extern int get_sha1_hex(const char *hex, unsigned char *sha1); extern int get_oid_hex(const char *hex, struct object_id *sha1); +/* + * Read `len` pairs of hexadecimal digits from `hex` and write the + * values to `binary` as `len` bytes. Return 0 on success, or -1 if + * the input does not consist of hex digits). + */ +extern int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); + /* * Convert a binary sha1 to its hex equivalent. The `_r` variant is reentrant, * and writes the NUL-terminated output to the buffer `out`, which must be at -- cgit v1.2.1