summaryrefslogtreecommitdiff
path: root/libavutil/dict.c
Commit message (Collapse)AuthorAgeFilesLines
* avutil/dict: Use av_dict_iterate in av_dict_get_stringMarvin Scholz2022-11-061-2/+2
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avutil/dict: Use av_dict_iterate in av_dict_copyMarvin Scholz2022-11-061-2/+2
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avutil/dict: Use av_dict_iterate in av_dict_getMarvin Scholz2022-11-061-10/+6
| | | | Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avutil/dict: Add av_dict_iterateMarvin Scholz2022-11-061-0/+19
| | | | | | | | This is a more explicit iteration API rather than using the "magic" av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX) which is not really trivial to grasp what it does when casually reading through code. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avutil/dict: Error out in case of key == NULLAndreas Rheinhardt2022-09-191-10/+17
| | | | | | | | | | | | | | | | | | | Up until now, using NULL as key in av_dict_get() on a non-empty AVDictionary would crash; using NULL as key in av_dict_set() would also crash for a non-empty AVDictionary unless AV_DICT_MULTIKEY was set; in case the dictionary was initially empty or AV_DICT_MULTIKEY was set, it was even possible for av_dict_set() to succeed when adding a NULL key, namely when one uses a value != NULL and the AV_DICT_DONT_STRDUP_VAL flag. Using av_dict_get() on such an AVDictionary will usually lead to crashes, though. Fix this by actually checking for key in both functions; error out if they are NULL. While just at it, also stop relying on av_strdup(NULL) to return NULL in av_dict_set(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: Improve appending valuesAndreas Rheinhardt2022-09-141-6/+7
| | | | | | | | | | | | | | When appending two values (due to AV_DICT_APPEND), the earlier code would first zero-allocate a buffer of the required size and then copy both parts into it via av_strlcat(). This is problematic, as it leads to quadratic performance in case of frequent enlargements. Fix this by using av_realloc() (which is hopefully designed to handle such cases in a better way than simply throwing the buffer we already have away) and by copying the string via memcpy() (after all, we already calculated the strlen of both strings). Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: Fix memleak when using AV_DICT_APPENDAndreas Rheinhardt2022-09-141-16/+12
| | | | | | | | | | | | | If a key already exists in an AVDictionary and the AV_DICT_APPEND flag is set, the old entry is at first discarded from the dictionary, but a pointer to the value is kept. Lateron enough memory to store the appended string is allocated; should this allocation fail, the old string is not freed and hence leaks. This commit changes this by moving creating the combined value to an earlier point in the function, which also ensures that the AVDictionary is unchanged in case of errors. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: Avoid check whose result is known in advanceAndreas Rheinhardt2022-09-141-4/+4
| | | | | | | | | We know that an AVDictionary is not empty if we have just added an entry to it, so only check for it being empty on the branch that does not do so. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: Move avpriv_dict_set_timestamp() to a header of its ownAndreas Rheinhardt2022-09-031-0/+1
| | | | | | | It is used almost nowhere, so it needn't be auto-included almost everywhere. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: av_realloc -> av_realloc_array()Limin Wang2020-06-061-2/+2
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat: factorize iso 8601 timestamp writer to a dictionary avutil functionMarton Balint2016-08-171-0/+17
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* Merge commit 'd12b5b2f135aade4099f4b26b0fe678656158c13'Derek Buitenhuis2016-05-111-114/+0
|\ | | | | | | | | | | | | | | * commit 'd12b5b2f135aade4099f4b26b0fe678656158c13': build: Split test programs off into separate files Some conversions done by: James Almer <jamrial@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* | lavu/dict: Add new flag to allow multiple equal keys.Thilo Borgmann2016-03-251-1/+4
| |
* | avutil/dict: do not realloc entries when deleting a non-existing itemMarton Balint2016-03-151-1/+1
| | | | | | | | | | | | | | | | Deleting a non-existing item should not invalidate existing entries returned with av_dict_get. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Marton Balint <cus@passwd.hu>
* | Merge commit '11c5f438ff83da5040e85bfa6299f56b321d32ef'Hendrik Leppkes2015-10-141-3/+8
|\ \ | |/ | | | | | | | | | | * commit '11c5f438ff83da5040e85bfa6299f56b321d32ef': dict: Change return type of av_dict_copy() Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * dict: Change return type of av_dict_copy()Vittorio Giovara2015-10-121-3/+8
| | | | | | | | | | | | av_dict_set() could return an error, so forward it appropriately. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * lavu: Check av_dict_set allocationsLuca Barbato2015-01-291-6/+11
| | | | | | | | | | Bug-Id: CID 1257772 Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | avutil/dict: Use size_t for appending stringsMichael Niedermayer2015-05-101-1/+1
| | | | | | | | | | | | the string length is not constrained to INT_MAX Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/dict: add more testsLukasz Marek2015-04-021-0/+53
| | | | | | | | Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
* | lavu/dict: fix set function when reuse existing key pointerLukasz Marek2015-04-021-20/+24
| | | | | | | | | | | | | | | | | | | | Fixes following scenario: av_dict_set(&d, "key", "old", 0); AVDictionaryEentry *e = av_dict_get(d, "key", NULL, 0); av_dict_set(&d, e->key, "new", 0); Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
* | lavu/dict: don't accept AV_DICT_DONT_STRDUP_VAL for av_dict_set_intLukasz Marek2015-04-021-0/+1
| | | | | | | | | | Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/dict: Use av_freep() to avoid leaving stale pointers in memoryMichael Niedermayer2014-12-271-5/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/dict: check for malloc failureswm42014-12-121-1/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil: remove FF_CONST_AVUTIL53, its no longer neededMichael Niedermayer2014-11-241-2/+2
| | | | | | | | | | | | version is 54 already Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/dict: add av_dict_get_stringLukasz Marek2014-11-211-0/+90
| | | | | | | | Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
* | Fix "passing argument 1 of av_free discards const qualifier from pointer ↵Michael Niedermayer2014-09-131-4/+4
| | | | | | | | | | | | target type" Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | dict.c: Free non-strduped av_dict_set arguments on error.Reimar Döffinger2014-08-231-0/+2
| | | | | | | | | | | | | | | | | | | | Unfortunately this was not explicitly documented and thus might be risky. But all uses I could find in FFmpeg and one in VLC had a memleak in these cases, and I could not find any that relied on the previous behaviour. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | dict.c: empty dictionaries should be a NULL pointer.Reimar Döffinger2014-08-161-2/+9
| | | | | | | | | | | | | | Ensure this is even the case if they are empty because we failed adding the first entry. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | dict.c: Add av_dict_set_int helper function.Reimar Döffinger2014-08-161-0/+8
| | | | | | | | | | | | | | This allows getting rid of the many, slightly differing, implementations of basically the same thing. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | dict.c: minor simplification.Reimar Döffinger2014-07-311-3/+2
| | | | | | | | Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | Merge commit '1619274fb393f55a365cc10f88faa173c9a8e772'Michael Niedermayer2014-06-091-1/+4
|\ \ | |/ | | | | | | | | | | * commit '1619274fb393f55a365cc10f88faa173c9a8e772': av_dict_set: fix potential memory leak with AV_DICT_DONT_OVERWRITE Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * av_dict_set: fix potential memory leak with AV_DICT_DONT_OVERWRITEJanne Grunau2014-06-091-1/+4
| | | | | | | | | | av_dict_set leaks it key/value arguments if AV_DICT_DONT_OVERWRITE is combined with AV_DICT_DONT_STRDUP_{KEY,VAL} and the key exists.
| * dict: const correctness for av_dict_get() and av_dict_copy()Diego Biurrun2014-06-051-2/+2
| |
* | avutil/dict: delay addition of const from ↵Michael Niedermayer2014-05-141-2/+2
| | | | | | | | | | | | | | | | e12a73246d8ce7d0fc4036522688934e26de4bb1 until next major ABI bump This unbreaks API Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | dict: const pointers to dictionary where possibleRoman Fietze2014-04-031-2/+2
| | | | | | | | | | | | | | | | | | | | This avoids temporaries or ugly casting in the calling code where const dictionaries are used. Esp. helpful when writing C++ wrappers for an AVDictionary having const member functions and CTORs with const references. Signed-off-by: Roman Fietze <roman.fietze@telemotive.de> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '93d216d37a3f95190ecb9d51cf72f54ea4e04ec7'Michael Niedermayer2014-03-071-21/+29
|\ \ | |/ | | | | | | | | | | | | | | | | * commit '93d216d37a3f95190ecb9d51cf72f54ea4e04ec7': dict: K&R formatting cosmetics Conflicts: libavutil/dict.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dict: K&R formatting cosmeticsPatrice Clement2014-03-071-23/+31
| |
| * Use the avstring.h locale-independent character type functionsReimar Döffinger2013-03-071-2/+1
| | | | | | | | | | | | Make sure the behavior does not change with the locale. Signed-off-by: Martin Storsjö <martin@martin.st>
* | lavu/dict: cosmetic realign.Clément Bœsch2013-04-131-4/+4
| |
* | Remove incorrect use of ctype.h functions.Reimar Döffinger2013-03-031-2/+1
| | | | | | | | | | | | | | As far as I can tell the code should not change behaviour depending on locale in any of these places. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | dict: fix memleakMichael Niedermayer2013-02-011-0/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | dict.c: use av_mallocz instead of av_reallocPaweł Hajdan, Jr2013-01-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memory passed to av_realloc must come from malloc, calloc or realloc, and not e.g. memalign. realloc(3): The realloc() function changes the size of the memory block pointed to by ptr to size bytes. (...) Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). The issue has been found by debugallocation, a part of google-perftools: http://code.google.com/p/gperftools/ . This makes fate pass when using LD_PRELOAD-ed debugallocation. See also earlier discussion http://ffmpeg.org/pipermail/ffmpeg-devel/2013-January/137234.html Signed-off-by: Paweł Hajdan, Jr <phajdan@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '38c1466ca41c73c7ce347da702362cb69c151716'Michael Niedermayer2013-01-261-0/+47
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | * commit '38c1466ca41c73c7ce347da702362cb69c151716': dict: add av_dict_parse_string() doc: support multitable in texi2pod Conflicts: doc/APIchanges libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dict: add av_dict_parse_string()Justin Ruggles2013-01-251-0/+47
| | | | | | | | | | | | Can be used to set multiple key/value pairs from a string. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2012-08-161-0/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: Fix even more missing includes after the common.h removal build: Factor out rangecoder dependencies to CONFIG_RANGECODER build: Factor out error resilience dependencies to CONFIG_ERROR_RESILIENCE x86: avcodec: Consistently name all init files Add more missing includes after removing the implicit common.h Add some more missing includes after removing the implicit common.h Don't include common.h from avutil.h rtmp: Automatically compute the hash for SWFVerification Conflicts: configure doc/APIchanges doc/examples/decoding_encoding.c libavcodec/Makefile libavcodec/assdec.c libavcodec/audio_frame_queue.c libavcodec/avpacket.c libavcodec/dv_profile.c libavcodec/dwt.c libavcodec/libtheoraenc.c libavcodec/rawdec.c libavcodec/rv40dsp.c libavcodec/tiff.c libavcodec/tiffenc.c libavcodec/v210dec.h libavcodec/vc1dsp.c libavcodec/x86/Makefile libavfilter/asrc_anullsrc.c libavfilter/avfilter.c libavfilter/buffer.c libavfilter/formats.c libavfilter/vf_ass.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_select.c libavfilter/video.c libavfilter/vsrc_testsrc.c libavformat/version.h libavutil/audioconvert.c libavutil/error.h libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Don't include common.h from avutil.hMartin Storsjö2012-08-151-0/+3
| | | | | | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2012-08-111-0/+10
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: lavf: simplify is_intra_only() by using codec descriptors. lavc: add an intra-only codec property. lavc: add codec descriptors. lavc: fix mixing CODEC_ID/AV_CODEC_ID in C++ code. dict: move struct AVDictionary definition to dict.c dict: add av_dict_count() Conflicts: doc/APIchanges libavcodec/old_codec_ids.h libavformat/utils.c libavutil/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dict: move struct AVDictionary definition to dict.cMans Rullgard2012-08-101-0/+5
| | | | | | | | | | | | | | This makes struct AVDictionary fully opaque now that nothing needs to access it directly any more. Signed-off-by: Mans Rullgard <mans@mansr.com>
| * dict: add av_dict_count()Mans Rullgard2012-08-101-0/+5
| | | | | | | | | | | | | | | | This adds a function to retrieve the number of entries in a dictionary and updates the places directly accessing what should be an opaque struct to use this new function instead. Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-11-071-1/+0
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (23 commits) x86inc: use sse versions of common macros instead of sse2 when applicable doc/APIchanges: add missing dates and hashes lavf: don't return from void av_update_cur_dts() Changelog: add more entries. Changelog: update ffmpeg/avconv incompatibility list. avconv: remove some redundant temporary variables. avconv: fix broken indentation avconv: move copy_initial_nonkeyframes to the options context. avconv: use file:stream instead of file.stream in log messages. doc/avconv: elaborate on basic functionality. doc/avconv: -sample_fmts, not -help sample_fmts prints the sample formats openssl: Only use CRYPTO_set_id_callback on OpenSSL < 1.0.0 Call avformat_network_init/deinit in the programs Remove leftover includes of strings.h avutil: Don't allow using strcasecmp/strncasecmp Replace all usage of strcasecmp/strncasecmp avstring: Add locale independent implementations of strcasecmp/strncasecmp avstring: Add locale independent implementations of toupper/tolower cosmetics: insert some spaces in explicit enum value assignments move 8SVX audio codecs to the audio codec list part on the next bump ... Conflicts: avprobe.c doc/APIchanges ffplay.c ffserver.c libavcodec/avcodec.h libavdevice/bktr.c libavdevice/v4l.c libavdevice/v4l2.c libavformat/matroskaenc.c libavformat/wtv.c libavutil/avstring.c libavutil/avstring.h libavutil/avutil.h libswscale/x86/swscale_template.c Merged-by: Michael Niedermayer <michaelni@gmx.at>