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
628edd6b
Commit
628edd6b
authored
Mar 07, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2167 from mekishizufu/memory_access_fixes
Fun with memory access
parents
0d95f6ec
79aa0302
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
21 deletions
+18
-21
src/blame.c
+9
-6
src/oid.c
+9
-15
No files found.
src/blame.c
View file @
628edd6b
...
...
@@ -20,12 +20,15 @@
static
int
hunk_byfinalline_search_cmp
(
const
void
*
key
,
const
void
*
entry
)
{
uint16_t
lineno
=
(
uint16_t
)
*
(
size_t
*
)
key
;
git_blame_hunk
*
hunk
=
(
git_blame_hunk
*
)
entry
;
if
(
lineno
<
hunk
->
final_start_line_number
)
size_t
lineno
=
*
(
size_t
*
)
key
;
size_t
lines_in_hunk
=
(
size_t
)
hunk
->
lines_in_hunk
;
size_t
final_start_line_number
=
(
size_t
)
hunk
->
final_start_line_number
;
if
(
lineno
<
final_start_line_number
)
return
-
1
;
if
(
lineno
>=
hunk
->
final_start_line_number
+
hunk
->
lines_in_hunk
)
if
(
lineno
>=
final_start_line_number
+
lines_in_hunk
)
return
1
;
return
0
;
}
...
...
@@ -95,7 +98,7 @@ static void shift_hunks_by(git_vector *v, size_t start_line, int shift_by)
{
size_t
i
;
if
(
!
git_vector_bsearch2
(
&
i
,
v
,
hunk_byfinalline_search_cmp
,
&
start_line
))
{
if
(
!
git_vector_bsearch2
(
&
i
,
v
,
hunk_byfinalline_search_cmp
,
&
start_line
))
{
for
(;
i
<
v
->
length
;
i
++
)
{
git_blame_hunk
*
hunk
=
(
git_blame_hunk
*
)
v
->
contents
[
i
];
hunk
->
final_start_line_number
+=
shift_by
;
...
...
@@ -161,10 +164,10 @@ const git_blame_hunk *git_blame_get_hunk_byindex(git_blame *blame, uint32_t inde
const
git_blame_hunk
*
git_blame_get_hunk_byline
(
git_blame
*
blame
,
uint32_t
lineno
)
{
size_t
i
;
size_t
i
,
new_lineno
=
(
size_t
)
lineno
;
assert
(
blame
);
if
(
!
git_vector_bsearch2
(
&
i
,
&
blame
->
hunks
,
hunk_byfinalline_search_cmp
,
&
lineno
))
{
if
(
!
git_vector_bsearch2
(
&
i
,
&
blame
->
hunks
,
hunk_byfinalline_search_cmp
,
&
new_
lineno
))
{
return
git_blame_get_hunk_byindex
(
blame
,
(
uint32_t
)
i
);
}
...
...
src/oid.c
View file @
628edd6b
...
...
@@ -24,30 +24,24 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
size_t
p
;
int
v
;
if
(
length
>
GIT_OID_HEXSZ
)
return
oid_error_invalid
(
"too long"
);
assert
(
out
&&
str
);
for
(
p
=
0
;
p
<
length
-
1
;
p
+=
2
)
{
v
=
(
git__fromhex
(
str
[
p
+
0
])
<<
4
)
|
git__fromhex
(
str
[
p
+
1
]);
if
(
!
length
)
return
oid_error_invalid
(
"too short"
);
if
(
v
<
0
)
return
oid_error_invalid
(
"contains invalid characters
"
);
if
(
length
>
GIT_OID_HEXSZ
)
return
oid_error_invalid
(
"too long
"
);
out
->
id
[
p
/
2
]
=
(
unsigned
char
)
v
;
}
memset
(
out
->
id
,
0
,
GIT_OID_RAWSZ
);
if
(
length
%
2
)
{
v
=
(
git__fromhex
(
str
[
p
+
0
])
<<
4
);
for
(
p
=
0
;
p
<
length
;
p
++
)
{
v
=
git__fromhex
(
str
[
p
]
);
if
(
v
<
0
)
return
oid_error_invalid
(
"contains invalid characters"
);
out
->
id
[
p
/
2
]
=
(
unsigned
char
)
v
;
p
+=
2
;
out
->
id
[
p
/
2
]
|=
(
unsigned
char
)(
v
<<
(
p
%
2
?
0
:
4
));
}
memset
(
out
->
id
+
p
/
2
,
0
,
(
GIT_OID_HEXSZ
-
p
)
/
2
);
return
0
;
}
...
...
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