Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
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
Linshizhi
ffmpeg.wasm-core
Commits
b3e2bb08
Commit
b3e2bb08
authored
Jun 03, 2012
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bprint: add av_bprint_init_for_buffer().
parent
9148ae5b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
bprint.c
libavutil/bprint.c
+14
-0
bprint.h
libavutil/bprint.h
+11
-0
No files found.
libavutil/bprint.c
View file @
b3e2bb08
...
...
@@ -78,6 +78,15 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
av_bprint_alloc
(
buf
,
size_init
-
1
);
}
void
av_bprint_init_for_buffer
(
AVBPrint
*
buf
,
char
*
buffer
,
unsigned
size
)
{
buf
->
str
=
buffer
;
buf
->
len
=
0
;
buf
->
size
=
size
;
buf
->
size_max
=
size
;
*
buf
->
str
=
0
;
}
void
av_bprintf
(
AVBPrint
*
buf
,
const
char
*
fmt
,
...)
{
unsigned
room
;
...
...
@@ -178,6 +187,7 @@ static void bprint_pascal(AVBPrint *b, unsigned size)
int
main
(
void
)
{
AVBPrint
b
;
char
buf
[
256
];
av_bprint_init
(
&
b
,
0
,
-
1
);
bprint_pascal
(
&
b
,
5
);
...
...
@@ -208,6 +218,10 @@ int main(void)
bprint_pascal
(
&
b
,
25
);
printf
(
"Long text count only buffer: %zu/%u
\n
"
,
strlen
(
b
.
str
),
b
.
len
);
av_bprint_init_for_buffer
(
&
b
,
buf
,
sizeof
(
buf
));
bprint_pascal
(
&
b
,
25
);
printf
(
"Long text count only buffer: %zu/%u
\n
"
,
strlen
(
buf
),
b
.
len
);
return
0
;
}
...
...
libavutil/bprint.h
View file @
b3e2bb08
...
...
@@ -99,6 +99,17 @@ void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
#define AV_BPRINT_SIZE_AUTOMATIC 1
#define AV_BPRINT_SIZE_COUNT_ONLY 0
/**
* Init a print buffer using a pre-existing buffer.
*
* The buffer will not be reallocated.
*
* @param buf buffer structure to init
* @param buffer byte buffer to use for the string data
* @param size size of buffer
*/
void
av_bprint_init_for_buffer
(
AVBPrint
*
buf
,
char
*
buffer
,
unsigned
size
);
/**
* Append a formated string to a print buffer.
*/
...
...
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