oidarray.c 860 Bytes
Newer Older
1 2 3 4 5 6 7 8
/*
 * Copyright (C) the libgit2 contributors. All rights reserved.
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */

#include "oidarray.h"
9 10

#include "git2/oidarray.h"
11 12
#include "array.h"

13
void git_oidarray_dispose(git_oidarray *arr)
14 15 16 17 18 19 20 21 22
{
	git__free(arr->ids);
}

void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array)
{
	arr->count = array->size;
	arr->ids = array->ptr;
}
23 24 25 26 27 28 29 30 31 32 33 34

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);
	}
}
35 36 37 38 39 40 41 42 43

#ifndef GIT_DEPRECATE_HARD

void git_oidarray_free(git_oidarray *arr)
{
	git_oidarray_dispose(arr);
}

#endif