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
1b9b37b8
Commit
1b9b37b8
authored
Jun 04, 2011
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dict: add AV_DICT_APPEND flag.
parent
25de5958
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
dict.c
libavutil/dict.c
+12
-1
dict.h
libavutil/dict.h
+2
-0
No files found.
libavutil/dict.c
View file @
1b9b37b8
...
...
@@ -19,6 +19,7 @@
*/
#include <strings.h>
#include "avstring.h"
#include "dict.h"
#include "internal.h"
#include "mem.h"
...
...
@@ -51,6 +52,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
{
AVDictionary
*
m
=
*
pm
;
AVDictionaryEntry
*
tag
=
av_dict_get
(
m
,
key
,
NULL
,
flags
);
char
*
oldval
=
NULL
;
if
(
!
m
)
m
=
*
pm
=
av_mallocz
(
sizeof
(
*
m
));
...
...
@@ -58,7 +60,10 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
if
(
tag
)
{
if
(
flags
&
AV_DICT_DONT_OVERWRITE
)
return
0
;
av_free
(
tag
->
value
);
if
(
flags
&
AV_DICT_APPEND
)
oldval
=
tag
->
value
;
else
av_free
(
tag
->
value
);
av_free
(
tag
->
key
);
*
tag
=
m
->
elems
[
--
m
->
count
];
}
else
{
...
...
@@ -75,6 +80,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
m
->
elems
[
m
->
count
].
key
=
av_strdup
(
key
);
if
(
flags
&
AV_DICT_DONT_STRDUP_VAL
)
{
m
->
elems
[
m
->
count
].
value
=
value
;
}
else
if
(
oldval
&&
flags
&
AV_DICT_APPEND
)
{
int
len
=
strlen
(
oldval
)
+
strlen
(
value
)
+
1
;
if
(
!
(
oldval
=
av_realloc
(
oldval
,
len
)))
return
AVERROR
(
ENOMEM
);
av_strlcat
(
oldval
,
value
,
len
);
m
->
elems
[
m
->
count
].
value
=
oldval
;
}
else
m
->
elems
[
m
->
count
].
value
=
av_strdup
(
value
);
m
->
count
++
;
...
...
libavutil/dict.h
View file @
1b9b37b8
...
...
@@ -29,6 +29,8 @@
#define AV_DICT_DONT_STRDUP_KEY 4
#define AV_DICT_DONT_STRDUP_VAL 8
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
#define AV_DICT_APPEND 32
/**< If the entry already exists, append to it. Note that no
delimiter is added, the strings are simply concatenated. */
typedef
struct
{
char
*
key
;
...
...
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