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
89602a1a
Commit
89602a1a
authored
Sep 29, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2584 from jacquesg/pool-alignment
Pool/Index data is not aligned
parents
ffe34a7c
0478b7f4
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
29 deletions
+43
-29
src/cc-compat.h
+8
-0
src/diff_patch.c
+1
-0
src/index.c
+29
-24
src/pack.c
+1
-1
src/pool.c
+1
-1
tests/merge/merge_helpers.c
+1
-1
tests/odb/foreach.c
+1
-1
tests/pack/packbuilder.c
+1
-1
No files found.
src/cc-compat.h
View file @
89602a1a
...
...
@@ -35,6 +35,14 @@
# define GIT_TYPEOF(x)
#endif
#if defined(__GNUC__)
# define GIT_ALIGN(x,size) x __attribute__ ((aligned(size)))
#elif defined(_MSC_VER)
# define GIT_ALIGN(x,size) __declspec(align(size)) x
#else
# define GIT_ALIGN(x,size) x
#endif
#define GIT_UNUSED(x) ((void)(x))
/* Define the printf format specifer to use for size_t output */
...
...
src/diff_patch.c
View file @
89602a1a
...
...
@@ -274,6 +274,7 @@ int git_diff_foreach(
return
error
;
memset
(
&
xo
,
0
,
sizeof
(
xo
));
memset
(
&
patch
,
0
,
sizeof
(
patch
));
diff_output_init
(
&
xo
.
output
,
&
diff
->
opts
,
file_cb
,
hunk_cb
,
data_cb
,
payload
);
git_xdiff_init
(
&
xo
,
&
diff
->
opts
);
...
...
src/index.c
View file @
89602a1a
...
...
@@ -1767,35 +1767,42 @@ static size_t read_entry(
git_index_entry
**
out
,
const
void
*
buffer
,
size_t
buffer_size
)
{
size_t
path_length
,
entry_size
;
uint16_t
flags_raw
;
const
char
*
path_ptr
;
const
struct
entry_short
*
source
=
buffer
;
struct
entry_short
source
;
git_index_entry
entry
=
{{
0
}};
if
(
INDEX_FOOTER_SIZE
+
minimal_entry_size
>
buffer_size
)
return
0
;
entry
.
ctime
.
seconds
=
(
git_time_t
)
ntohl
(
source
->
ctime
.
seconds
);
entry
.
ctime
.
nanoseconds
=
ntohl
(
source
->
ctime
.
nanoseconds
);
entry
.
mtime
.
seconds
=
(
git_time_t
)
ntohl
(
source
->
mtime
.
seconds
);
entry
.
mtime
.
nanoseconds
=
ntohl
(
source
->
mtime
.
nanoseconds
);
entry
.
dev
=
ntohl
(
source
->
dev
);
entry
.
ino
=
ntohl
(
source
->
ino
);
entry
.
mode
=
ntohl
(
source
->
mode
);
entry
.
uid
=
ntohl
(
source
->
uid
);
entry
.
gid
=
ntohl
(
source
->
gid
);
entry
.
file_size
=
ntohl
(
source
->
file_size
);
git_oid_cpy
(
&
entry
.
id
,
&
source
->
oid
);
entry
.
flags
=
ntohs
(
source
->
flags
);
/* buffer is not guaranteed to be aligned */
memcpy
(
&
source
,
buffer
,
sizeof
(
struct
entry_short
));
entry
.
ctime
.
seconds
=
(
git_time_t
)
ntohl
(
source
.
ctime
.
seconds
);
entry
.
ctime
.
nanoseconds
=
ntohl
(
source
.
ctime
.
nanoseconds
);
entry
.
mtime
.
seconds
=
(
git_time_t
)
ntohl
(
source
.
mtime
.
seconds
);
entry
.
mtime
.
nanoseconds
=
ntohl
(
source
.
mtime
.
nanoseconds
);
entry
.
dev
=
ntohl
(
source
.
dev
);
entry
.
ino
=
ntohl
(
source
.
ino
);
entry
.
mode
=
ntohl
(
source
.
mode
);
entry
.
uid
=
ntohl
(
source
.
uid
);
entry
.
gid
=
ntohl
(
source
.
gid
);
entry
.
file_size
=
ntohl
(
source
.
file_size
);
git_oid_cpy
(
&
entry
.
id
,
&
source
.
oid
);
entry
.
flags
=
ntohs
(
source
.
flags
);
if
(
entry
.
flags
&
GIT_IDXENTRY_EXTENDED
)
{
const
struct
entry_long
*
source_l
=
(
const
struct
entry_long
*
)
source
;
path_ptr
=
source_l
->
path
;
uint16_t
flags_raw
;
size_t
flags_offset
;
flags_raw
=
ntohs
(
source_l
->
flags_extended
);
memcpy
(
&
entry
.
flags_extended
,
&
flags_raw
,
2
);
flags_offset
=
offsetof
(
struct
entry_long
,
flags_extended
);
memcpy
(
&
flags_raw
,
(
const
char
*
)
buffer
+
flags_offset
,
sizeof
(
flags_raw
));
flags_raw
=
ntohs
(
flags_raw
);
memcpy
(
&
entry
.
flags_extended
,
&
flags_raw
,
sizeof
(
flags_raw
));
path_ptr
=
(
const
char
*
)
buffer
+
offsetof
(
struct
entry_long
,
path
);
}
else
path_ptr
=
source
->
path
;
path_ptr
=
(
const
char
*
)
buffer
+
offsetof
(
struct
entry_short
,
path
)
;
path_length
=
entry
.
flags
&
GIT_IDXENTRY_NAMEMASK
;
...
...
@@ -1846,14 +1853,12 @@ static int read_header(struct index_header *dest, const void *buffer)
static
size_t
read_extension
(
git_index
*
index
,
const
char
*
buffer
,
size_t
buffer_size
)
{
const
struct
index_extension
*
source
;
struct
index_extension
dest
;
size_t
total_size
;
source
=
(
const
struct
index_extension
*
)(
buffer
);
memcpy
(
dest
.
signature
,
source
->
signature
,
4
);
dest
.
extension_size
=
ntohl
(
source
->
extension_size
);
/* buffer is not guaranteed to be aligned */
memcpy
(
&
dest
,
buffer
,
sizeof
(
struct
index_extension
));
dest
.
extension_size
=
ntohl
(
dest
.
extension_size
);
total_size
=
dest
.
extension_size
+
sizeof
(
struct
index_extension
);
...
...
src/pack.c
View file @
89602a1a
...
...
@@ -620,7 +620,7 @@ int git_packfile_unpack(
struct
pack_chain_elem
*
elem
=
NULL
,
*
stack
;
git_pack_cache_entry
*
cached
=
NULL
;
struct
pack_chain_elem
small_stack
[
SMALL_STACK_SIZE
];
size_t
stack_size
,
elem_pos
;
size_t
stack_size
=
0
,
elem_pos
;
git_otype
base_type
;
/*
...
...
src/pool.c
View file @
89602a1a
...
...
@@ -7,7 +7,7 @@ struct git_pool_page {
git_pool_page
*
next
;
uint32_t
size
;
uint32_t
avail
;
char
data
[
GIT_FLEX_ARRAY
]
;
GIT_ALIGN
(
char
data
[
GIT_FLEX_ARRAY
],
8
)
;
};
struct
pool_freelist
{
...
...
tests/merge/merge_helpers.c
View file @
89602a1a
...
...
@@ -327,7 +327,7 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
int
dircount
(
void
*
payload
,
git_buf
*
pathbuf
)
{
in
t
*
entries
=
payload
;
size_
t
*
entries
=
payload
;
size_t
len
=
git_buf_len
(
pathbuf
);
if
(
len
<
5
||
strcmp
(
pathbuf
->
ptr
+
(
git_buf_len
(
pathbuf
)
-
5
),
"/.git"
)
!=
0
)
...
...
tests/odb/foreach.c
View file @
89602a1a
...
...
@@ -87,7 +87,7 @@ void test_odb_foreach__files_in_objects_dir(void)
git_repository
*
repo
;
git_odb
*
odb
;
git_buf
buf
=
GIT_BUF_INIT
;
size_
t
nobj
=
0
;
in
t
nobj
=
0
;
cl_fixture_sandbox
(
"testrepo.git"
);
cl_git_pass
(
git_repository_open
(
&
repo
,
"testrepo.git"
));
...
...
tests/pack/packbuilder.c
View file @
89602a1a
...
...
@@ -47,7 +47,7 @@ void test_pack_packbuilder__cleanup(void)
git_indexer_free
(
_indexer
);
_indexer
=
NULL
;
p_chdir
(
".."
);
cl_git_pass
(
p_chdir
(
".."
)
);
cl_git_sandbox_cleanup
();
_repo
=
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