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
eb58e2d0
Commit
eb58e2d0
authored
Jun 12, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'arrbee/minor-paranoia' into development
parents
3b5001b4
3e9e6cda
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
63 additions
and
16 deletions
+63
-16
src/cache.c
+6
-3
src/config.c
+3
-1
src/diff.c
+2
-0
src/global.c
+4
-2
src/index.c
+2
-0
src/odb.c
+2
-0
src/pack-objects.c
+3
-0
src/pack.c
+19
-3
src/refdb.c
+1
-0
src/repository.c
+2
-3
src/thread-utils.h
+1
-1
src/util.c
+10
-0
src/util.h
+8
-3
No files found.
src/cache.c
View file @
eb58e2d0
...
...
@@ -66,9 +66,12 @@ void git_cache_dump_stats(git_cache *cache)
int
git_cache_init
(
git_cache
*
cache
)
{
cache
->
used_memory
=
0
;
memset
(
cache
,
0
,
sizeof
(
*
cache
))
;
cache
->
map
=
git_oidmap_alloc
();
git_mutex_init
(
&
cache
->
lock
);
if
(
git_mutex_init
(
&
cache
->
lock
))
{
giterr_set
(
GITERR_OS
,
"Failed to initialize cache mutex"
);
return
-
1
;
}
return
0
;
}
...
...
@@ -102,9 +105,9 @@ void git_cache_clear(git_cache *cache)
void
git_cache_free
(
git_cache
*
cache
)
{
git_cache_clear
(
cache
);
git_oidmap_free
(
cache
->
map
);
git_mutex_free
(
&
cache
->
lock
);
git__memset
(
cache
,
0
,
sizeof
(
*
cache
));
}
/* Called with lock */
...
...
src/config.c
View file @
eb58e2d0
...
...
@@ -40,12 +40,14 @@ static void config_free(git_config *cfg)
size_t
i
;
file_internal
*
internal
;
for
(
i
=
0
;
i
<
cfg
->
files
.
length
;
++
i
)
{
for
(
i
=
0
;
i
<
cfg
->
files
.
length
;
++
i
)
{
internal
=
git_vector_get
(
&
cfg
->
files
,
i
);
GIT_REFCOUNT_DEC
(
internal
,
file_internal_free
);
}
git_vector_free
(
&
cfg
->
files
);
git__memset
(
cfg
,
0
,
sizeof
(
*
cfg
));
git__free
(
cfg
);
}
...
...
src/diff.c
View file @
eb58e2d0
...
...
@@ -465,6 +465,8 @@ static void diff_list_free(git_diff_list *diff)
git_pathspec_free
(
&
diff
->
pathspec
);
git_pool_clear
(
&
diff
->
pool
);
git__memset
(
diff
,
0
,
sizeof
(
*
diff
));
git__free
(
diff
);
}
...
...
src/global.c
View file @
eb58e2d0
...
...
@@ -61,7 +61,8 @@ int git_threads_init(void)
return
0
;
_tls_index
=
TlsAlloc
();
git_mutex_init
(
&
git__mwindow_mutex
);
if
(
git_mutex_init
(
&
git__mwindow_mutex
))
return
-
1
;
/* Initialize any other subsystems that have global state */
if
((
error
=
git_hash_global_init
())
>=
0
)
...
...
@@ -121,7 +122,8 @@ int git_threads_init(void)
if
(
_tls_init
)
return
0
;
git_mutex_init
(
&
git__mwindow_mutex
);
if
(
git_mutex_init
(
&
git__mwindow_mutex
))
return
-
1
;
pthread_key_create
(
&
_tls_key
,
&
cb__free_status
);
/* Initialize any other subsystems that have global state */
...
...
src/index.c
View file @
eb58e2d0
...
...
@@ -348,6 +348,8 @@ static void index_free(git_index *index)
git_vector_free
(
&
index
->
reuc
);
git__free
(
index
->
index_file_path
);
git__memset
(
index
,
0
,
sizeof
(
*
index
));
git__free
(
index
);
}
...
...
src/odb.c
View file @
eb58e2d0
...
...
@@ -589,6 +589,8 @@ static void odb_free(git_odb *db)
git_vector_free
(
&
db
->
backends
);
git_cache_free
(
&
db
->
own_cache
);
git__memset
(
db
,
0
,
sizeof
(
*
db
));
git__free
(
db
);
}
...
...
src/pack-objects.c
View file @
eb58e2d0
...
...
@@ -132,7 +132,10 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo)
if
(
git_mutex_init
(
&
pb
->
cache_mutex
)
||
git_mutex_init
(
&
pb
->
progress_mutex
)
||
git_cond_init
(
&
pb
->
progress_cond
))
{
giterr_set
(
GITERR_OS
,
"Failed to initialize packbuilder mutex"
);
goto
on_error
;
}
#endif
...
...
src/pack.c
View file @
eb58e2d0
...
...
@@ -85,15 +85,27 @@ static void cache_free(git_pack_cache *cache)
git_offmap_free
(
cache
->
entries
);
git_mutex_free
(
&
cache
->
lock
);
}
memset
(
cache
,
0
,
sizeof
(
*
cache
));
}
static
int
cache_init
(
git_pack_cache
*
cache
)
{
memset
(
cache
,
0
,
sizeof
(
git_pack_cache
));
memset
(
cache
,
0
,
sizeof
(
*
cache
));
cache
->
entries
=
git_offmap_alloc
();
GITERR_CHECK_ALLOC
(
cache
->
entries
);
cache
->
memory_limit
=
GIT_PACK_CACHE_MEMORY_LIMIT
;
git_mutex_init
(
&
cache
->
lock
);
if
(
git_mutex_init
(
&
cache
->
lock
))
{
giterr_set
(
GITERR_OS
,
"Failed to initialize pack cache mutex"
);
git__free
(
cache
->
entries
);
cache
->
entries
=
NULL
;
return
-
1
;
}
return
0
;
}
...
...
@@ -944,7 +956,11 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
p
->
mtime
=
(
git_time_t
)
st
.
st_mtime
;
p
->
index_version
=
-
1
;
git_mutex_init
(
&
p
->
lock
);
if
(
git_mutex_init
(
&
p
->
lock
))
{
giterr_set
(
GITERR_OS
,
"Failed to initialize packfile mutex"
);
git__free
(
p
);
return
-
1
;
}
/* see if we can parse the sha1 oid in the packfile name */
if
(
path_len
<
40
||
...
...
src/refdb.c
View file @
eb58e2d0
...
...
@@ -89,6 +89,7 @@ int git_refdb_compress(git_refdb *db)
void
git_refdb__free
(
git_refdb
*
db
)
{
refdb_free_backend
(
db
);
git__memset
(
db
,
0
,
sizeof
(
*
db
));
git__free
(
db
);
}
...
...
src/repository.c
View file @
eb58e2d0
...
...
@@ -119,6 +119,7 @@ void git_repository_free(git_repository *repo)
git__free
(
repo
->
workdir
);
git__free
(
repo
->
namespace
);
git__memset
(
repo
,
0
,
sizeof
(
*
repo
));
git__free
(
repo
);
}
...
...
@@ -145,12 +146,10 @@ static bool valid_repository_path(git_buf *repository_path)
static
git_repository
*
repository_alloc
(
void
)
{
git_repository
*
repo
=
git__
malloc
(
sizeof
(
git_repository
));
git_repository
*
repo
=
git__
calloc
(
1
,
sizeof
(
git_repository
));
if
(
!
repo
)
return
NULL
;
memset
(
repo
,
0x0
,
sizeof
(
git_repository
));
if
(
git_cache_init
(
&
repo
->
objects
)
<
0
)
{
git__free
(
repo
);
return
NULL
;
...
...
src/thread-utils.h
View file @
eb58e2d0
...
...
@@ -138,7 +138,7 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
/* Pthreads Mutex */
#define git_mutex unsigned int
#define git_mutex_init(a)
(void)
0
#define git_mutex_init(a) 0
#define git_mutex_lock(a) 0
#define git_mutex_unlock(a) (void)0
#define git_mutex_free(a) (void)0
...
...
src/util.c
View file @
eb58e2d0
...
...
@@ -722,3 +722,13 @@ void git__insertsort_r(
if
(
freeswap
)
git__free
(
swapel
);
}
void
git__memset
(
void
*
data
,
int
c
,
size_t
size
)
{
volatile
uint8_t
*
scan
=
data
;
uint8_t
*
end
=
scan
+
size
;
uint8_t
val
=
(
uint8_t
)
c
;
while
(
scan
<
end
)
*
scan
++
=
val
;
}
src/util.h
View file @
eb58e2d0
...
...
@@ -295,8 +295,7 @@ GIT_INLINE(bool) git__iswildcard(int c)
}
/*
* Parse a string value as a boolean, just like Core Git
* does.
* Parse a string value as a boolean, just like Core Git does.
*
* Valid values for true are: 'true', 'yes', 'on'
* Valid values for false are: 'false', 'no', 'off'
...
...
@@ -311,7 +310,7 @@ extern int git__parse_bool(int *out, const char *value);
* - "July 17, 2003"
* - "2003-7-17 08:23"
*/
int
git__date_parse
(
git_time_t
*
out
,
const
char
*
date
);
extern
int
git__date_parse
(
git_time_t
*
out
,
const
char
*
date
);
/*
* Unescapes a string in-place.
...
...
@@ -322,4 +321,10 @@ int git__date_parse(git_time_t *out, const char *date);
*/
extern
size_t
git__unescape
(
char
*
str
);
/*
* Memset that will not be optimized away by the compiler.
* You usually should just use regular `memset()`.
*/
extern
void
git__memset
(
void
*
data
,
int
c
,
size_t
size
);
#endif
/* INCLUDE_util_h__ */
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