proxy.c 1.04 KB
Newer Older
1 2 3 4 5 6 7
/*
 * 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.
 */

8 9
#include "proxy.h"

10 11
#include "git2/proxy.h"

12
int git_proxy_options_init(git_proxy_options *opts, unsigned int version)
13 14 15 16 17
{
	GIT_INIT_STRUCTURE_FROM_TEMPLATE(
		opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
	return 0;
}
18

19
#ifndef GIT_DEPRECATE_HARD
20 21 22 23
int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
{
	return git_proxy_options_init(opts, version);
}
24
#endif
25

26 27 28
int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
{
	if (!src) {
29
		git_proxy_options_init(tgt, GIT_PROXY_OPTIONS_VERSION);
30 31 32 33 34 35
		return 0;
	}

	memcpy(tgt, src, sizeof(git_proxy_options));
	if (src->url) {
		tgt->url = git__strdup(src->url);
36
		GIT_ERROR_CHECK_ALLOC(tgt->url);
37 38 39 40
	}

	return 0;
}
41

42
void git_proxy_options_dispose(git_proxy_options *opts)
43
{
44 45 46
	if (!opts)
		return;

47 48 49
	git__free((char *) opts->url);
	opts->url = NULL;
}