Commit 9ffa33a1 by Edward Thomson

oid: introduce `git_oid_raw_cpy`

Now that oids are type-aware, they use their type to understand how many
bytes to copy.  Some callers may need to copy the raw bytes of the
object id.

This is equivalent to a memcpy that is a little more semantic.
parent 6d8c7cab
...@@ -187,8 +187,7 @@ int git_oid_fromraw(git_oid *out, const unsigned char *raw) ...@@ -187,8 +187,7 @@ int git_oid_fromraw(git_oid *out, const unsigned char *raw)
int git_oid_cpy(git_oid *out, const git_oid *src) int git_oid_cpy(git_oid *out, const git_oid *src)
{ {
memcpy(out->id, src->id, sizeof(out->id)); return git_oid_raw_cpy(out->id, src->id);
return 0;
} }
int git_oid_cmp(const git_oid *a, const git_oid *b) int git_oid_cmp(const git_oid *a, const git_oid *b)
......
...@@ -55,6 +55,14 @@ GIT_INLINE(int) git_oid_raw_cmp( ...@@ -55,6 +55,14 @@ GIT_INLINE(int) git_oid_raw_cmp(
return memcmp(sha1, sha2, GIT_OID_RAWSZ); return memcmp(sha1, sha2, GIT_OID_RAWSZ);
} }
GIT_INLINE(int) git_oid_raw_cpy(
unsigned char *dst,
const unsigned char *src)
{
memcpy(dst, src, GIT_OID_RAWSZ);
return 0;
}
/* /*
* Compare two oid structures. * Compare two oid structures.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment