]> git.proxmox.com Git - libgit2.git/blob - src/proxy.c
treebuilder: fix memory leaks in `write_with_buffer`
[libgit2.git] / src / proxy.c
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7
8 #include "common.h"
9 #include "git2/proxy.h"
10
11 int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
12 {
13 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
14 opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
15 return 0;
16 }
17
18 int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
19 {
20 if (!src) {
21 git_proxy_init_options(tgt, GIT_PROXY_OPTIONS_VERSION);
22 return 0;
23 }
24
25 memcpy(tgt, src, sizeof(git_proxy_options));
26 if (src->url) {
27 tgt->url = git__strdup(src->url);
28 GITERR_CHECK_ALLOC(tgt->url);
29 }
30
31 return 0;
32 }