ffmpeg.libavutil.mem

Undocumented in source.

Members

Functions

av_calloc
void* av_calloc(size_t nmemb, size_t size)

Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block. The allocation will fail if nmemb * size is greater than or equal to INT_MAX. @param nmemb @param size @return Pointer to the allocated block, NULL if it cannot be allocated.

av_dynarray2_add
void* av_dynarray2_add(void** tab_ptr, int* nb_ptr, size_t elem_size, uint8_t* elem_data)

Add an element of size elem_size to a dynamic array.

av_dynarray_add
void av_dynarray_add(void* tab_ptr, int* nb_ptr, void* elem)

Add an element to a dynamic array.

av_dynarray_add_nofree
int av_dynarray_add_nofree(void* tab_ptr, int* nb_ptr, void* elem)

Add an element to a dynamic array.

av_fast_malloc
void av_fast_malloc(void* ptr, uint* size, size_t min_size)

Allocate a buffer, reusing the given one if large enough.

av_fast_mallocz
void av_fast_mallocz(void* ptr, uint* size, size_t min_size)

Allocate a buffer, reusing the given one if large enough.

av_fast_realloc
void* av_fast_realloc(void* ptr, uint* size, size_t min_size)

Reallocate the given block if it is not large enough, otherwise do nothing.

av_free
void av_free(void* ptr)

Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). @param ptr Pointer to the memory block which should be freed. @note ptr = NULL is explicitly allowed. @note It is recommended that you use av_freep() instead. @see av_freep()

av_freep
void av_freep(void* ptr)

Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer pointing to it to NULL. @param ptr Pointer to the pointer to the memory block which should be freed. @note passing a pointer to a NULL pointer is safe and leads to no action. @see av_free()

av_malloc
void* av_malloc(size_t size)

Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU). @param size Size in bytes for the memory block to be allocated. @return Pointer to the allocated block, NULL if the block cannot be allocated. @see av_mallocz()

av_mallocz
void* av_mallocz(size_t size)

Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block. @param size Size in bytes for the memory block to be allocated. @return Pointer to the allocated block, NULL if it cannot be allocated. @see av_malloc()

av_max_alloc
void av_max_alloc(size_t max)

Set the maximum size that may me allocated in one block.

av_memcpy_backptr
void av_memcpy_backptr(uint8_t* dst, int back, int cnt)

deliberately overlapping memcpy implementation @param dst destination buffer @param back how many bytes back we start (the initial size of the overlapping window), must be > 0 @param cnt number of bytes to copy, must be >= 0

av_memdup
void* av_memdup(void* p, size_t size)

Duplicate the buffer p. @param p buffer to be duplicated @return Pointer to a newly allocated buffer containing a copy of p or NULL if the buffer cannot be allocated.

av_realloc
void* av_realloc(void* ptr, size_t size)

Allocate or reallocate a block of memory. If ptr is NULL and size > 0, allocate a new block. If size is zero, free the memory block pointed to by ptr. @param ptr Pointer to a memory block already allocated with av_malloc(z)() or av_realloc() or NULL. @param size Size in bytes for the memory block to be allocated or reallocated. @return Pointer to a newly reallocated block or NULL if the block cannot be reallocated or the function is used to free the memory block. @see av_fast_realloc()

av_realloc_array
void* av_realloc_array(void* ptr, size_t nmemb, size_t size)

Allocate or reallocate an array. If ptr is NULL and nmemb > 0, allocate a new block. If nmemb is zero, free the memory block pointed to by ptr. @param ptr Pointer to a memory block already allocated with av_realloc() or NULL. @param nmemb Number of elements @param size Size of the single element @return Pointer to a newly-reallocated block or NULL if the block cannot be reallocated or the function is used to free the memory block. @warning Pointers originating from the av_malloc() family of functions must not be passed to av_realloc(). The former can be implemented using memalign() (or other functions), and there is no guarantee that pointers from such functions can be passed to realloc() at all. The situation is undefined according to POSIX and may crash with some libc implementations.

av_realloc_f
void* av_realloc_f(void* ptr, size_t nelem, size_t elsize)

Allocate or reallocate a block of memory. This function does the same thing as av_realloc, except: - It takes two arguments and checks the result of the multiplication for integer overflow. - It frees the input block in case of failure, thus avoiding the memory leak with the classic "buf = realloc(buf); if (!buf) return -1;".

av_reallocp
int av_reallocp(void* ptr, size_t size)

Allocate or reallocate a block of memory. If *ptr is NULL and size > 0, allocate a new block. If size is zero, free the memory block pointed to by ptr. @param ptr Pointer to a pointer to a memory block already allocated with av_realloc(), or pointer to a pointer to NULL. The pointer is updated on success, or freed on failure. @param size Size in bytes for the memory block to be allocated or reallocated @return Zero on success, an AVERROR error code on failure. @warning Pointers originating from the av_malloc() family of functions must not be passed to av_reallocp(). The former can be implemented using memalign() (or other functions), and there is no guarantee that pointers from such functions can be passed to realloc() at all. The situation is undefined according to POSIX and may crash with some libc implementations.

av_reallocp_array
int av_reallocp_array(void* ptr, size_t nmemb, size_t size)

Allocate or reallocate an array through a pointer to a pointer. If *ptr is NULL and nmemb > 0, allocate a new block. If nmemb is zero, free the memory block pointed to by ptr. @param ptr Pointer to a pointer to a memory block already allocated with av_realloc(), or pointer to a pointer to NULL. The pointer is updated on success, or freed on failure. @param nmemb Number of elements @param size Size of the single element @return Zero on success, an AVERROR error code on failure. @warning Pointers originating from the av_malloc() family of functions must not be passed to av_realloc(). The former can be implemented using memalign() (or other functions), and there is no guarantee that pointers from such functions can be passed to realloc() at all. The situation is undefined according to POSIX and may crash with some libc implementations.

av_strdup
char* av_strdup(char* s)

Duplicate the string s. @param s string to be duplicated @return Pointer to a newly allocated string containing a copy of s or NULL if the string cannot be allocated.

av_strndup
char* av_strndup(char* s, size_t len)

Duplicate a substring of the string s. @param s string to be duplicated @param len the maximum length of the resulting string (not counting the terminating byte). @return Pointer to a newly-allocated string containing a copy of s or NULL if the string cannot be allocated.

Static functions

av_malloc_array
void* av_malloc_array(size_t nmemb, size_t size)

Helper function to allocate a block of size * nmemb bytes with using av_malloc() @param nmemb Number of elements @param size Size of the single element @return Pointer to the allocated block, NULL if the block cannot be allocated. @see av_malloc()

av_mallocz_array
void* av_mallocz_array(size_t nmemb, size_t size)

Allocate a block of size * nmemb bytes with av_mallocz(). @param nmemb Number of elements @param size Size of the single element @return Pointer to the allocated block, NULL if the block cannot be allocated. @see av_mallocz() @see av_malloc_array()

av_size_mult
int av_size_mult(size_t a, size_t b, size_t* r)

Multiply two size_t values checking for overflow. @return 0 if success, AVERROR(EINVAL) if overflow.

Meta