line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 "util.h" |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "common.h" |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
int git_strarray_copy(git_strarray *tgt, const git_strarray *src) |
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
size_t i; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
assert(tgt && src); |
|
|
0
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
memset(tgt, 0, sizeof(*tgt)); |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if (!src->count) |
21
|
0
|
|
|
|
|
|
return 0; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
tgt->strings = git__calloc(src->count, sizeof(char *)); |
24
|
0
|
0
|
|
|
|
|
GIT_ERROR_CHECK_ALLOC(tgt->strings); |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
for (i = 0; i < src->count; ++i) { |
27
|
0
|
0
|
|
|
|
|
if (!src->strings[i]) |
28
|
0
|
|
|
|
|
|
continue; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
tgt->strings[tgt->count] = git__strdup(src->strings[i]); |
31
|
0
|
0
|
|
|
|
|
if (!tgt->strings[tgt->count]) { |
32
|
0
|
|
|
|
|
|
git_strarray_dispose(tgt); |
33
|
0
|
|
|
|
|
|
memset(tgt, 0, sizeof(*tgt)); |
34
|
0
|
|
|
|
|
|
return -1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
tgt->count++; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
28
|
|
|
|
|
|
void git_strarray_dispose(git_strarray *array) |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
size_t i; |
46
|
|
|
|
|
|
|
|
47
|
28
|
50
|
|
|
|
|
if (array == NULL) |
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
|
50
|
41
|
100
|
|
|
|
|
for (i = 0; i < array->count; ++i) |
51
|
13
|
|
|
|
|
|
git__free(array->strings[i]); |
52
|
|
|
|
|
|
|
|
53
|
28
|
|
|
|
|
|
git__free(array->strings); |
54
|
|
|
|
|
|
|
|
55
|
28
|
|
|
|
|
|
memset(array, 0, sizeof(*array)); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#ifndef GIT_DEPRECATE_HARD |
59
|
6
|
|
|
|
|
|
void git_strarray_free(git_strarray *array) |
60
|
|
|
|
|
|
|
{ |
61
|
6
|
|
|
|
|
|
git_strarray_dispose(array); |
62
|
6
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
#endif |