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
92e0b679
Commit
92e0b679
authored
Nov 21, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer: Do not `put` anything if len is 0
parent
6f446176
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
src/buffer.c
+7
-4
tests/core/buffer.c
+2
-3
No files found.
src/buffer.c
View file @
92e0b679
...
...
@@ -176,10 +176,13 @@ int git_buf_putcn(git_buf *buf, char c, size_t len)
int
git_buf_put
(
git_buf
*
buf
,
const
char
*
data
,
size_t
len
)
{
ENSURE_SIZE
(
buf
,
buf
->
size
+
len
+
1
);
memmove
(
buf
->
ptr
+
buf
->
size
,
data
,
len
);
buf
->
size
+=
len
;
buf
->
ptr
[
buf
->
size
]
=
'\0'
;
if
(
len
)
{
assert
(
data
);
ENSURE_SIZE
(
buf
,
buf
->
size
+
len
+
1
);
memmove
(
buf
->
ptr
+
buf
->
size
,
data
,
len
);
buf
->
size
+=
len
;
buf
->
ptr
[
buf
->
size
]
=
'\0'
;
}
return
0
;
}
...
...
tests/core/buffer.c
View file @
92e0b679
...
...
@@ -281,11 +281,10 @@ check_buf_append_abc(
/* more variations on append tests */
void
test_core_buffer__5
(
void
)
{
check_buf_append
(
""
,
""
,
""
,
0
,
8
);
check_buf_append
(
"a"
,
""
,
"a"
,
1
,
8
);
check_buf_append
(
""
,
""
,
""
,
0
,
0
);
check_buf_append
(
"a"
,
""
,
"a"
,
1
,
0
);
check_buf_append
(
""
,
"a"
,
"a"
,
1
,
8
);
check_buf_append
(
""
,
"a"
,
"a"
,
1
,
8
);
check_buf_append
(
"a"
,
""
,
"a"
,
1
,
8
);
check_buf_append
(
"a"
,
"b"
,
"ab"
,
2
,
8
);
check_buf_append
(
""
,
"abcdefgh"
,
"abcdefgh"
,
8
,
16
);
check_buf_append
(
"abcdefgh"
,
""
,
"abcdefgh"
,
8
,
16
);
...
...
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