Le 31/05/2024 à 23:44, Michael Niedermayer a écrit : > On Fri, May 31, 2024 at 11:06:49PM +0200, averne wrote: >> Le 30/05/2024 à 22:38, Rémi Denis-Courmont a écrit : >>> Le torstaina 30. toukokuuta 2024, 22.43.03 EEST averne a écrit : >>>> This is useful eg. for memory-mapped buffers that need page-aligned memory, >>>> when dealing with hardware devices >>>> >>>> Signed-off-by: averne <averne...@gmail.com> >>>> --- >>>> libavutil/buffer.c | 31 +++++++++++++++++++++++++++++++ >>>> libavutil/buffer.h | 7 +++++++ >>>> 2 files changed, 38 insertions(+) >>>> >>>> diff --git a/libavutil/buffer.c b/libavutil/buffer.c >>>> index e4562a79b1..b8e357f540 100644 >>>> --- a/libavutil/buffer.c >>>> +++ b/libavutil/buffer.c >>>> @@ -16,9 +16,14 @@ >>>> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >>>> 02110-1301 >>>> USA */ >>>> >>>> +#include "config.h" >>>> + >>>> #include <stdatomic.h> >>>> #include <stdint.h> >>>> #include <string.h> >>>> +#if HAVE_MALLOC_H >>>> +#include <malloc.h> >>>> +#endif >>>> >>>> #include "avassert.h" >>>> #include "buffer_internal.h" >>>> @@ -100,6 +105,32 @@ AVBufferRef *av_buffer_allocz(size_t size) >>>> return ret; >>>> } >>>> >>>> +AVBufferRef *av_buffer_aligned_alloc(size_t size, size_t align) >>>> +{ >>>> + AVBufferRef *ret = NULL; >>>> + uint8_t *data = NULL; >>>> + >>>> +#if HAVE_POSIX_MEMALIGN >>>> + if (posix_memalign((void **)&data, align, size)) >>> >>> Invalid cast. >>> >> >> Neither gcc or clang emit a warning here, even on -Weverything. >> What would be your idea of a valid cast then? First cast to intptr_t, >> then void** ? >> >>>> + return NULL; >>>> +#elif HAVE_ALIGNED_MALLOC >>>> + data = aligned_alloc(align, size); > > on mingw64: > > src/libavutil/buffer.c: In function ‘av_buffer_aligned_alloc’: > src/libavutil/buffer.c:117:12: error: implicit declaration of function > ‘aligned_alloc’ [-Werror=implicit-function-declaration] > 117 | data = aligned_alloc(align, size); > | ^~~~~~~~~~~~~ > > thx
Missing include of stdlib.h, probably. Will fix, thanks. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".