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
baaf1c47
Commit
baaf1c47
authored
May 02, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer: Add `git_buf_vprintf`
parent
3fbcac89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
src/buffer.c
+22
-6
src/buffer.h
+1
-0
No files found.
src/buffer.c
View file @
baaf1c47
...
...
@@ -146,17 +146,21 @@ int git_buf_puts(git_buf *buf, const char *string)
return
git_buf_put
(
buf
,
string
,
strlen
(
string
));
}
int
git_buf_
printf
(
git_buf
*
buf
,
const
char
*
format
,
...
)
int
git_buf_
vprintf
(
git_buf
*
buf
,
const
char
*
format
,
va_list
ap
)
{
int
len
;
va_list
arglist
;
ENSURE_SIZE
(
buf
,
buf
->
size
+
1
);
ENSURE_SIZE
(
buf
,
buf
->
size
+
(
strlen
(
format
)
*
2
)
);
while
(
1
)
{
va_start
(
arglist
,
format
);
len
=
p_vsnprintf
(
buf
->
ptr
+
buf
->
size
,
buf
->
asize
-
buf
->
size
,
format
,
arglist
);
va_end
(
arglist
);
va_list
args
;
va_copy
(
args
,
ap
);
len
=
p_vsnprintf
(
buf
->
ptr
+
buf
->
size
,
buf
->
asize
-
buf
->
size
,
format
,
args
);
if
(
len
<
0
)
{
git__free
(
buf
->
ptr
);
...
...
@@ -175,6 +179,18 @@ int git_buf_printf(git_buf *buf, const char *format, ...)
return
0
;
}
int
git_buf_printf
(
git_buf
*
buf
,
const
char
*
format
,
...)
{
int
r
;
va_list
ap
;
va_start
(
ap
,
format
);
r
=
git_buf_vprintf
(
buf
,
format
,
ap
);
va_end
(
ap
);
return
r
;
}
void
git_buf_copy_cstr
(
char
*
data
,
size_t
datasize
,
const
git_buf
*
buf
)
{
size_t
copylen
;
...
...
src/buffer.h
View file @
baaf1c47
...
...
@@ -76,6 +76,7 @@ int git_buf_putc(git_buf *buf, char c);
int
git_buf_put
(
git_buf
*
buf
,
const
char
*
data
,
size_t
len
);
int
git_buf_puts
(
git_buf
*
buf
,
const
char
*
string
);
int
git_buf_printf
(
git_buf
*
buf
,
const
char
*
format
,
...)
GIT_FORMAT_PRINTF
(
2
,
3
);
int
git_buf_vprintf
(
git_buf
*
buf
,
const
char
*
format
,
va_list
ap
);
void
git_buf_clear
(
git_buf
*
buf
);
void
git_buf_consume
(
git_buf
*
buf
,
const
char
*
end
);
void
git_buf_truncate
(
git_buf
*
buf
,
size_t
len
);
...
...
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