Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
a9746b30
Commit
a9746b30
authored
May 29, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strarray: move to its own file
parent
629515a8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
46 deletions
+56
-46
src/strarray.c
+56
-0
src/util.c
+0
-46
No files found.
src/strarray.c
0 → 100644
View file @
a9746b30
/*
* 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 "util.h"
#include "common.h"
int
git_strarray_copy
(
git_strarray
*
tgt
,
const
git_strarray
*
src
)
{
size_t
i
;
assert
(
tgt
&&
src
);
memset
(
tgt
,
0
,
sizeof
(
*
tgt
));
if
(
!
src
->
count
)
return
0
;
tgt
->
strings
=
git__calloc
(
src
->
count
,
sizeof
(
char
*
));
GIT_ERROR_CHECK_ALLOC
(
tgt
->
strings
);
for
(
i
=
0
;
i
<
src
->
count
;
++
i
)
{
if
(
!
src
->
strings
[
i
])
continue
;
tgt
->
strings
[
tgt
->
count
]
=
git__strdup
(
src
->
strings
[
i
]);
if
(
!
tgt
->
strings
[
tgt
->
count
])
{
git_strarray_free
(
tgt
);
memset
(
tgt
,
0
,
sizeof
(
*
tgt
));
return
-
1
;
}
tgt
->
count
++
;
}
return
0
;
}
void
git_strarray_free
(
git_strarray
*
array
)
{
size_t
i
;
if
(
array
==
NULL
)
return
;
for
(
i
=
0
;
i
<
array
->
count
;
++
i
)
git__free
(
array
->
strings
[
i
]);
git__free
(
array
->
strings
);
memset
(
array
,
0
,
sizeof
(
*
array
));
}
src/util.c
View file @
a9746b30
...
@@ -22,52 +22,6 @@
...
@@ -22,52 +22,6 @@
# include <Shlwapi.h>
# include <Shlwapi.h>
#endif
#endif
void
git_strarray_free
(
git_strarray
*
array
)
{
size_t
i
;
if
(
array
==
NULL
)
return
;
for
(
i
=
0
;
i
<
array
->
count
;
++
i
)
git__free
(
array
->
strings
[
i
]);
git__free
(
array
->
strings
);
memset
(
array
,
0
,
sizeof
(
*
array
));
}
int
git_strarray_copy
(
git_strarray
*
tgt
,
const
git_strarray
*
src
)
{
size_t
i
;
assert
(
tgt
&&
src
);
memset
(
tgt
,
0
,
sizeof
(
*
tgt
));
if
(
!
src
->
count
)
return
0
;
tgt
->
strings
=
git__calloc
(
src
->
count
,
sizeof
(
char
*
));
GIT_ERROR_CHECK_ALLOC
(
tgt
->
strings
);
for
(
i
=
0
;
i
<
src
->
count
;
++
i
)
{
if
(
!
src
->
strings
[
i
])
continue
;
tgt
->
strings
[
tgt
->
count
]
=
git__strdup
(
src
->
strings
[
i
]);
if
(
!
tgt
->
strings
[
tgt
->
count
])
{
git_strarray_free
(
tgt
);
memset
(
tgt
,
0
,
sizeof
(
*
tgt
));
return
-
1
;
}
tgt
->
count
++
;
}
return
0
;
}
int
git__strntol64
(
int64_t
*
result
,
const
char
*
nptr
,
size_t
nptr_len
,
const
char
**
endptr
,
int
base
)
int
git__strntol64
(
int64_t
*
result
,
const
char
*
nptr
,
size_t
nptr_len
,
const
char
**
endptr
,
int
base
)
{
{
const
char
*
p
;
const
char
*
p
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment