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
3a4c8788
Commit
3a4c8788
authored
Apr 27, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/ffeval: use av_dynarray2_add()
Simplify, increment robustness.
parent
e3984166
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
18 deletions
+14
-18
ffeval.c
tools/ffeval.c
+14
-18
No files found.
tools/ffeval.c
View file @
3a4c8788
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#endif
#endif
#include "libavutil/eval.h"
#include "libavutil/eval.h"
#include "libavutil/mem.h"
#if !HAVE_GETOPT
#if !HAVE_GETOPT
#include "compat/getopt.c"
#include "compat/getopt.c"
...
@@ -47,20 +48,26 @@ static void usage(void)
...
@@ -47,20 +48,26 @@ static void usage(void)
"-p PROMPT set output prompt
\n
"
);
"-p PROMPT set output prompt
\n
"
);
}
}
#define MAX_BLOCK_SIZE SIZE_MAX
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
size_t
buf_size
=
256
;
int
buf_size
=
0
;
char
*
buf
=
av_malloc
(
buf_size
)
;
char
*
buf
=
NULL
;
const
char
*
outfilename
=
NULL
,
*
infilename
=
NULL
;
const
char
*
outfilename
=
NULL
,
*
infilename
=
NULL
;
FILE
*
outfile
=
NULL
,
*
infile
=
NULL
;
FILE
*
outfile
=
NULL
,
*
infile
=
NULL
;
const
char
*
prompt
=
"=> "
;
const
char
*
prompt
=
"=> "
;
int
count
=
0
,
echo
=
0
;
int
count
=
0
,
echo
=
0
;
int
c
;
int
c
;
av_max_alloc
(
MAX_BLOCK_SIZE
);
#define GROW_ARRAY() \
do { \
if (!av_dynarray2_add((void **)&buf, &buf_size, 1, NULL)) { \
av_log(NULL, AV_LOG_ERROR, \
"Memory allocation problem occurred\n"); \
return 1; \
} \
} while (0)
GROW_ARRAY
();
while
((
c
=
getopt
(
argc
,
argv
,
"ehi:o:p:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"ehi:o:p:"
))
!=
-
1
)
{
switch
(
c
)
{
switch
(
c
)
{
case
'e'
:
case
'e'
:
...
@@ -120,19 +127,8 @@ int main(int argc, char **argv)
...
@@ -120,19 +127,8 @@ int main(int argc, char **argv)
}
}
count
=
0
;
count
=
0
;
}
else
{
}
else
{
if
(
count
>=
buf_size
-
1
)
{
if
(
count
>=
buf_size
-
1
)
if
(
buf_size
==
MAX_BLOCK_SIZE
)
{
GROW_ARRAY
();
av_log
(
NULL
,
AV_LOG_ERROR
,
"Memory allocation problem, "
"max block size '%zd' reached
\n
"
,
MAX_BLOCK_SIZE
);
return
1
;
}
buf_size
=
FFMIN
(
buf_size
,
MAX_BLOCK_SIZE
/
2
)
*
2
;
buf
=
av_realloc_f
((
void
*
)
buf
,
buf_size
,
1
);
if
(
!
buf
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Memory allocation problem occurred
\n
"
);
return
1
;
}
}
buf
[
count
++
]
=
c
;
buf
[
count
++
]
=
c
;
}
}
}
}
...
...
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