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
abfdb8a6
Commit
abfdb8a6
authored
May 23, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_pool_init: return an int
Let `git_pool_init` return an int so that it could fail.
parent
e4bdba56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
src/pool.c
+6
-2
src/pool.h
+1
-1
No files found.
src/pool.c
View file @
abfdb8a6
...
@@ -37,7 +37,7 @@ size_t git_pool__system_page_size(void)
...
@@ -37,7 +37,7 @@ size_t git_pool__system_page_size(void)
}
}
#ifndef GIT_DEBUG_POOL
#ifndef GIT_DEBUG_POOL
void
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
)
int
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
)
{
{
assert
(
pool
);
assert
(
pool
);
assert
(
item_size
>=
1
);
assert
(
item_size
>=
1
);
...
@@ -45,6 +45,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
...
@@ -45,6 +45,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
memset
(
pool
,
0
,
sizeof
(
git_pool
));
memset
(
pool
,
0
,
sizeof
(
git_pool
));
pool
->
item_size
=
item_size
;
pool
->
item_size
=
item_size
;
pool
->
page_size
=
git_pool__system_page_size
();
pool
->
page_size
=
git_pool__system_page_size
();
return
0
;
}
}
void
git_pool_clear
(
git_pool
*
pool
)
void
git_pool_clear
(
git_pool
*
pool
)
...
@@ -125,7 +127,7 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
...
@@ -125,7 +127,7 @@ static int git_pool__ptr_cmp(const void * a, const void * b)
}
}
}
}
void
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
)
int
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
)
{
{
assert
(
pool
);
assert
(
pool
);
assert
(
item_size
>=
1
);
assert
(
item_size
>=
1
);
...
@@ -134,6 +136,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
...
@@ -134,6 +136,8 @@ void git_pool_init(git_pool *pool, size_t item_size)
pool
->
item_size
=
item_size
;
pool
->
item_size
=
item_size
;
pool
->
page_size
=
git_pool__system_page_size
();
pool
->
page_size
=
git_pool__system_page_size
();
git_vector_init
(
&
pool
->
allocations
,
100
,
git_pool__ptr_cmp
);
git_vector_init
(
&
pool
->
allocations
,
100
,
git_pool__ptr_cmp
);
return
0
;
}
}
void
git_pool_clear
(
git_pool
*
pool
)
void
git_pool_clear
(
git_pool
*
pool
)
...
...
src/pool.h
View file @
abfdb8a6
...
@@ -81,7 +81,7 @@ typedef struct {
...
@@ -81,7 +81,7 @@ typedef struct {
* Of course, you can use this in other ways, but those are the
* Of course, you can use this in other ways, but those are the
* two most common patterns.
* two most common patterns.
*/
*/
extern
void
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
);
extern
int
git_pool_init
(
git_pool
*
pool
,
size_t
item_size
);
/**
/**
* Free all items in pool
* Free all items in pool
...
...
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