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
45489a11
Unverified
Commit
45489a11
authored
Aug 27, 2021
by
Edward Thomson
Committed by
GitHub
Aug 27, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6008 from boretrk/array
git_array_alloc: return objects of correct type
parents
34e685c0
f062eb62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/array.h
+8
-8
No files found.
src/array.h
View file @
45489a11
...
...
@@ -41,8 +41,8 @@
typedef
git_array_t
(
char
)
git_array_generic_t
;
/* use a generic array for growth
so this can return the new item
*/
GIT_INLINE
(
void
*
)
git_array_grow
(
void
*
_a
,
size_t
item_size
)
/* use a generic array for growth
, return 0 on success
*/
GIT_INLINE
(
int
)
git_array_grow
(
void
*
_a
,
size_t
item_size
)
{
volatile
git_array_generic_t
*
a
=
_a
;
size_t
new_size
;
...
...
@@ -59,18 +59,18 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
if
((
new_array
=
git__reallocarray
(
a
->
ptr
,
new_size
,
item_size
))
==
NULL
)
goto
on_oom
;
a
->
ptr
=
new_array
;
a
->
asize
=
new_size
;
a
->
size
++
;
return
a
->
ptr
+
(
a
->
size
-
1
)
*
item_size
;
a
->
ptr
=
new_array
;
a
->
asize
=
new_size
;
return
0
;
on_oom
:
git_array_clear
(
*
a
);
return
NULL
;
return
-
1
;
}
#define git_array_alloc(a) \
(((a).size >= (a).asize) ? \
git_array_grow(&(a), sizeof(*(a).ptr)) : \
((a).ptr ? &(a).ptr[(a).size++] : (void *)NULL))
(((a).size < (a).asize || git_array_grow(&(a), sizeof(*(a).ptr)) == 0) ? \
&(a).ptr[(a).size++] : (void *)NULL)
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : (void *)NULL)
...
...
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