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
81201a4c
Commit
81201a4c
authored
May 15, 2011
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move cache.c to the new error handling
parent
3abe3bba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
5 deletions
+17
-5
src/cache.c
+4
-2
src/cache.h
+1
-1
src/odb.c
+5
-1
src/repository.c
+7
-1
No files found.
src/cache.c
View file @
81201a4c
...
...
@@ -32,7 +32,7 @@
#define GIT_CACHE_OPENADR 3
void
git_cache_init
(
git_cache
*
cache
,
size_t
size
,
git_cached_obj_freeptr
free_ptr
)
int
git_cache_init
(
git_cache
*
cache
,
size_t
size
,
git_cached_obj_freeptr
free_ptr
)
{
size_t
i
;
...
...
@@ -51,7 +51,9 @@ void git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_p
cache
->
lru_count
=
0
;
cache
->
free_obj
=
free_ptr
;
cache
->
nodes
=
git__malloc
((
size
+
1
)
*
sizeof
(
cache_node
));
//TODO: How should we deal with GIT_ENOMEM?
cache
->
nodes
=
git__malloc
((
size
+
1
)
*
sizeof
(
cache_node
));
if
(
cache
->
nodes
==
NULL
)
return
GIT_ENOMEM
;
for
(
i
=
0
;
i
<
(
size
+
1
);
++
i
)
{
git_mutex_init
(
&
cache
->
nodes
[
i
].
lock
);
...
...
src/cache.h
View file @
81201a4c
...
...
@@ -31,7 +31,7 @@ typedef struct {
}
git_cache
;
void
git_cache_init
(
git_cache
*
cache
,
size_t
size
,
git_cached_obj_freeptr
free_ptr
);
int
git_cache_init
(
git_cache
*
cache
,
size_t
size
,
git_cached_obj_freeptr
free_ptr
);
void
git_cache_free
(
git_cache
*
cache
);
void
*
git_cache_try_store
(
git_cache
*
cache
,
void
*
entry
);
...
...
src/odb.c
View file @
81201a4c
...
...
@@ -234,13 +234,17 @@ static int backend_sort_cmp(const void *a, const void *b)
int
git_odb_new
(
git_odb
**
out
)
{
int
error
;
git_odb
*
db
=
git__calloc
(
1
,
sizeof
(
*
db
));
if
(
!
db
)
return
GIT_ENOMEM
;
git_cache_init
(
&
db
->
cache
,
GIT_DEFAULT_CACHE_SIZE
,
&
free_odb_object
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
if
(
git_vector_init
(
&
db
->
backends
,
4
,
backend_sort_cmp
)
<
0
)
{
if
(
git_vector_init
(
&
db
->
backends
,
4
,
backend_sort_cmp
)
<
GIT_SUCCESS
)
{
free
(
db
);
return
GIT_ENOMEM
;
}
...
...
src/repository.c
View file @
81201a4c
...
...
@@ -159,13 +159,19 @@ static int guess_repository_dirs(git_repository *repo, const char *repository_pa
static
git_repository
*
repository_alloc
()
{
int
error
;
git_repository
*
repo
=
git__malloc
(
sizeof
(
git_repository
));
if
(
!
repo
)
return
NULL
;
memset
(
repo
,
0x0
,
sizeof
(
git_repository
));
git_cache_init
(
&
repo
->
objects
,
GIT_DEFAULT_CACHE_SIZE
,
&
git_object__free
);
error
=
git_cache_init
(
&
repo
->
objects
,
GIT_DEFAULT_CACHE_SIZE
,
&
git_object__free
);
if
(
error
<
GIT_SUCCESS
)
{
free
(
repo
);
return
NULL
;
}
if
(
git_repository__refcache_init
(
&
repo
->
references
)
<
GIT_SUCCESS
)
{
free
(
repo
);
...
...
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