summaryrefslogtreecommitdiff
path: root/src/oidarray.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-01-21 18:01:20 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-02-04 10:29:41 +0000
commited51feb74b33ca115ddf739ce3574a76cb7a6fa6 (patch)
treef2eb026fdb35cf8860b2313573abd10c274a472d /src/oidarray.c
parent7bd89502d818681ee220282d890891d9c11abeb1 (diff)
downloadlibgit2-ed51feb74b33ca115ddf739ce3574a76cb7a6fa6.tar.gz
oidarray: introduce git_oidarray__reverse
Provide a simple function to reverse an oidarray.
Diffstat (limited to 'src/oidarray.c')
-rw-r--r--src/oidarray.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/oidarray.c b/src/oidarray.c
index fda3b638d..e70e9dd61 100644
--- a/src/oidarray.c
+++ b/src/oidarray.c
@@ -20,3 +20,15 @@ void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array)
arr->count = array->size;
arr->ids = array->ptr;
}
+
+void git_oidarray__reverse(git_oidarray *arr)
+{
+ size_t i;
+ git_oid tmp;
+
+ for (i = 0; i < arr->count / 2; i++) {
+ git_oid_cpy(&tmp, &arr->ids[i]);
+ git_oid_cpy(&arr->ids[i], &arr->ids[(arr->count-1)-i]);
+ git_oid_cpy(&arr->ids[(arr->count-1)-i], &tmp);
+ }
+}