summaryrefslogtreecommitdiffstats
path: root/libavutil/buffer.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit '27079a426c9d3db918b158976e44b9b143d78e1c'Clément Bœsch2017-03-221-11/+12
|\ | | | | | | | | | | | | * commit '27079a426c9d3db918b158976e44b9b143d78e1c': buffer: convert to stdatomic Merged-by: Clément Bœsch <u@pkh.me>
| * buffer: convert to stdatomicAnton Khirnov2016-10-021-10/+11
| |
* | lavu/buffer: drop USE_ATOMICSClément Bœsch2017-03-221-71/+0
| | | | | | | | | | | | | | USE_ATOMICS is only set if there is no thread implementation enabled, in which case you can't expect any lock mechanism from FFmpeg. This is also conflicting with the incoming use of stdatomic.
* | Merge commit '24a362569bff1d4161742fffaca80a4a4428be8a'Clément Bœsch2017-03-161-1/+1
|\ \ | |/ | | | | | | | | | | * commit '24a362569bff1d4161742fffaca80a4a4428be8a': buffer: fix av_buffer_realloc() when the data is offset wrt buffer start Merged-by: Clément Bœsch <u@pkh.me>
| * buffer: fix av_buffer_realloc() when the data is offset wrt buffer startAnton Khirnov2016-08-031-1/+1
| | | | | | | | | | | | | | | | | | In such a case behave as if the buffer was not reallocatable -- allocate a new one and copy the data (preserving just the part described by the reference passed to av_buffer_realloc). CC: libav-stable@libav.org Reported-By: wm4 <nfxjfg@googlemail.com>
* | Merge commit '721a4efc0545548a241080b53ab480e34f366240'Derek Buitenhuis2016-02-171-1/+26
|\ \ | |/ | | | | | | | | | | * commit '721a4efc0545548a241080b53ab480e34f366240': buffer: add support for pools using caller data in allocation Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * buffer: add support for pools using caller data in allocationAnton Khirnov2016-02-141-1/+26
| | | | | | | | | | This should allow using more complex allocators than simple malloc wrappers.
* | avutil/buffer: Avoid moving the AVBufferRef to a new place in memory in ↵Michael Niedermayer2015-03-121-2/+2
| | | | | | | | | | | | | | | | | | av_buffer_make_writable() This allows making a AVBufferRef writable without the need to update all pointers to it Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: Avoid moving the AVBufferRef to a new place in memory in ↵Michael Niedermayer2015-03-121-2/+1
| | | | | | | | | | | | | | | | | | av_buffer_realloc() This allows reallocating AVBufferRefs without the need to update all pointers to it Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: factor buffer_replace() outMichael Niedermayer2015-01-231-5/+16
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: add #if USE_ATOMICS around atomics specific functions to ↵Michael Niedermayer2014-12-061-0/+2
| | | | | | | | | | | | | | | | ensure sync types arent mixed by mistake Fixes CID1257011 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: Move USE_ATOMICS to thread.h to avoid it becoming out of sync ↵Michael Niedermayer2014-11-291-2/+0
| | | | | | | | | | | | with it Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'fbd6c97f9ca858140df16dd07200ea0d4bdc1a83'Michael Niedermayer2014-11-271-1/+35
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'fbd6c97f9ca858140df16dd07200ea0d4bdc1a83': lavu: fix memory leaks by using a mutex instead of atomics Conflicts: libavutil/buffer.c The atomics code is left in place as a fallback for synchronization in the absence of p/w32 threads. Our ABI did not requires applications to only use threads (and matching ones) to what libavutil was build with Our code also was not affected by the leak this change fixes, though no question the atomics based implementation is not pretty at all. First and foremost the code must work, being pretty comes after that. If this causes problems, for example when libavutil is used by multiple applications each using a different kind of threading system then the default possibly has to be changed to the uglier atomics. See: cea3a63ba3d89d8403eef008f7a7c54d645cff70 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * lavu: fix memory leaks by using a mutex instead of atomicswm42014-11-271-54/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The buffer pool has to atomically add and remove entries from the linked list of available buffers. This was done by removing the entire list with a CAS operation, working on it, and then setting it back again (using a retry-loop in case another thread was doing the same thing). This could effectively cause memory leaks: while a thread was working on the buffer list, other threads would allocate new buffers, increasing the pool's total size. There was no real leak, but since these extra buffers were not needed, but not free'd either (except when the buffer pool was destroyed), this had the same effects as a real leak. For some reason, growth was exponential, and could easily kill the process due to OOM in real-world uses. Fix this by using a mutex to protect the list operations. The fancy way atomics remove the whole list to work on it is not needed anymore, which also avoids the situation which was causing the leak. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | Revert "lavu/buffer: add release function"Lukasz Marek2014-03-061-29/+0
| | | | | | | | | | | | This reverts commit 3144440004941aa22ffea9933f5e5dfe826df654. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/buffer: add release functionLukasz Marek2014-02-251-0/+29
| | | | | | | | | | | | | | new function allows to unref buffer and obtain its data. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu: define FF_MEMORY_POISON and use itStefano Sabatini2013-05-131-1/+1
| | | | | | | | Allow single-place definition of constant used to fill poisoned memory.
* | avutil: add av_buffer_get_ref_count()Michael Niedermayer2013-03-301-0/+5
| | | | | | | | | | | | This function is quite usefull for debuging Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: add get_opaqueXidorn Quan2013-03-291-0/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: remove redundant memory poisoningMichael Niedermayer2013-03-241-3/+0
| | | | | | | | | | Found-by: ubitux Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: support memory poisoningMichael Niedermayer2013-03-241-0/+7
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/add_to_pool: remove unused assgnmentMichael Niedermayer2013-03-191-1/+1
| | | | | | | | | | Fixed CID991859 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/buffer: Fix race in pool.Michael Niedermayer2013-03-181-0/+7
| | | | | | | | | | | | | | | | | | | | This race will always happen sooner or later in a multi-threaded environment and it will over time lead to OOM. This fix works by spinning, there are other ways by which this can be fixed, like simply detecting the issue after it happened and freeing the over-allocated memory or simply using a mutex. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/get_pool: remove dead operations whichs result is never used.Michael Niedermayer2013-03-171-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/get_pool: Remove redundant initial atomic operationMichael Niedermayer2013-03-171-3/+3
| | | | | | | | | | | | 602->442 dezicycles Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | buffer: use the atomic get instead of the add and fetch variant.Clément Bœsch2013-03-121-1/+1
| |
* | Merge commit '1cec0624d0e6f48590283a57169b58b9fe8449d3'Michael Niedermayer2013-03-081-0/+143
|\ \ | |/ | | | | | | | | | | * commit '1cec0624d0e6f48590283a57169b58b9fe8449d3': AVBuffer: add a new API for buffer pools Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * AVBuffer: add a new API for buffer poolsAnton Khirnov2013-03-081-0/+143
| |
* | Merge commit '8e401dbe90cc77b1f3067a917d9fa48cefa3fcdb'Michael Niedermayer2013-03-081-4/+4
|/ | | | | | | | | | * commit '8e401dbe90cc77b1f3067a917d9fa48cefa3fcdb': lavu: add a new API for reference-counted data buffers. Conflicts: libavutil/Makefile Merged-by: Michael Niedermayer <michaelni@gmx.at>
* lavu: add a new API for reference-counted data buffers.Anton Khirnov2013-03-081-0/+194
OpenPOWER on IntegriCloud