]> git.ipfire.org Git - thirdparty/git.git/commit - notes.c
hex_to_bytes(): simpler replacement for `get_oid_hex_segment()`
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 26 Aug 2017 08:28:11 +0000 (10:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 26 Aug 2017 16:21:01 +0000 (09:21 -0700)
commitcfdc88f1a34ccb8e59899501b0ede875afac0d83
treeb9ae15a82d3b2002e34fb63e4a57aacedf9a1277
parentd49852d6f89bfde3cb20b6ca5866f67f6c04a894
hex_to_bytes(): simpler replacement for `get_oid_hex_segment()`

Now that `get_oid_hex_segment()` does less, it makes sense to rename
it and simplify its semantics:

* Instead of a `hex_len` parameter, which was the number of hex
  characters (and had to be even), use a `len` parameter, which is the
  number of resulting bytes. This removes then need for the check that
  `hex_len` is even and to divide it by two to determine the number of
  bytes. For good hygiene, declare the `len` parameter to be `size_t`
  instead of `unsigned int`.

* Change the order of the arguments to the more traditional (dst,
  src, len).

* Rename the function to `hex_to_bytes()`.

* Remove a loop variable: just count `len` down instead.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c