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
a6dd5865
Commit
a6dd5865
authored
Apr 05, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer: use GIT_ASSERT
parent
7d24070d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
src/buf_text.c
+2
-2
src/buffer.c
+11
-8
No files found.
src/buf_text.c
View file @
a6dd5865
...
...
@@ -69,7 +69,7 @@ int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src)
size_t
new_size
;
char
*
out
;
assert
(
tgt
!=
src
);
GIT_ASSERT
(
tgt
!=
src
);
if
(
!
next
)
return
git_buf_set
(
tgt
,
src
->
ptr
,
src
->
size
);
...
...
@@ -116,7 +116,7 @@ int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src)
const
char
*
next
=
memchr
(
scan
,
'\n'
,
src
->
size
);
size_t
alloclen
;
assert
(
tgt
!=
src
);
GIT_ASSERT
(
tgt
!=
src
);
if
(
!
next
)
return
git_buf_set
(
tgt
,
src
->
ptr
,
src
->
size
);
...
...
src/buffer.c
View file @
a6dd5865
...
...
@@ -225,7 +225,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
if
(
len
)
{
size_t
new_size
;
assert
(
data
);
GIT_ASSERT_ARG
(
data
);
GIT_ERROR_CHECK_ALLOC_ADD
(
&
new_size
,
buf
->
size
,
len
);
GIT_ERROR_CHECK_ALLOC_ADD
(
&
new_size
,
new_size
,
1
);
...
...
@@ -239,7 +239,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
int
git_buf_puts
(
git_buf
*
buf
,
const
char
*
string
)
{
assert
(
string
);
GIT_ASSERT_ARG
(
string
);
return
git_buf_put
(
buf
,
string
,
strlen
(
string
));
}
...
...
@@ -319,7 +320,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
return
-
1
;
}
assert
(
len
%
4
==
0
);
GIT_ASSERT_ARG
(
len
%
4
==
0
);
GIT_ERROR_CHECK_ALLOC_ADD
(
&
new_size
,
(
len
/
4
*
3
),
buf
->
size
);
GIT_ERROR_CHECK_ALLOC_ADD
(
&
new_size
,
new_size
,
1
);
ENSURE_SIZE
(
buf
,
new_size
);
...
...
@@ -760,7 +761,7 @@ int git_buf_join(
/* not safe to have str_b point internally to the buffer */
if
(
buf
->
size
)
assert
(
str_b
<
buf
->
ptr
||
str_b
>=
buf
->
ptr
+
buf
->
size
);
GIT_ASSERT_ARG
(
str_b
<
buf
->
ptr
||
str_b
>=
buf
->
ptr
+
buf
->
size
);
/* figure out if we need to insert a separator */
if
(
separator
&&
strlen_a
)
{
...
...
@@ -810,9 +811,9 @@ int git_buf_join3(
char
*
tgt
;
/* for this function, disallow pointers into the existing buffer */
assert
(
str_a
<
buf
->
ptr
||
str_a
>=
buf
->
ptr
+
buf
->
size
);
assert
(
str_b
<
buf
->
ptr
||
str_b
>=
buf
->
ptr
+
buf
->
size
);
assert
(
str_c
<
buf
->
ptr
||
str_c
>=
buf
->
ptr
+
buf
->
size
);
GIT_ASSERT
(
str_a
<
buf
->
ptr
||
str_a
>=
buf
->
ptr
+
buf
->
size
);
GIT_ASSERT
(
str_b
<
buf
->
ptr
||
str_b
>=
buf
->
ptr
+
buf
->
size
);
GIT_ASSERT
(
str_c
<
buf
->
ptr
||
str_c
>=
buf
->
ptr
+
buf
->
size
);
if
(
separator
)
{
if
(
len_a
>
0
)
{
...
...
@@ -885,7 +886,9 @@ int git_buf_splice(
char
*
splice_loc
;
size_t
new_size
,
alloc_size
;
assert
(
buf
&&
where
<=
buf
->
size
&&
nb_to_remove
<=
buf
->
size
-
where
);
GIT_ASSERT
(
buf
);
GIT_ASSERT
(
where
<=
buf
->
size
);
GIT_ASSERT
(
nb_to_remove
<=
buf
->
size
-
where
);
splice_loc
=
buf
->
ptr
+
where
;
...
...
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