|
FFmpeg
4.2.2
|
Functions responsible for allocating, freeing, and copying memory. More...
Functions | |
| void * | av_malloc (size_t size) av_malloc_attrib |
| Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU). More... | |
| void * | av_mallocz (size_t size) av_malloc_attrib |
| Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block. More... | |
| void * | av_malloc_array (size_t nmemb, size_t size) |
| Allocate a memory block for an array with av_malloc(). More... | |
| void * | av_mallocz_array (size_t nmemb, size_t size) |
| Allocate a memory block for an array with av_mallocz(). More... | |
| void * | av_calloc (size_t nmemb, size_t size) av_malloc_attrib |
| Non-inlined equivalent of av_mallocz_array(). More... | |
| void * | av_realloc (void *ptr, size_t size) |
| Allocate, reallocate, or free a block of memory. More... | |
| av_warn_unused_result int | av_reallocp (void *ptr, size_t size) |
| Allocate, reallocate, or free a block of memory through a pointer to a pointer. More... | |
| void * | av_realloc_f (void *ptr, size_t nelem, size_t elsize) |
| Allocate, reallocate, or free a block of memory. More... | |
| void * | av_realloc_array (void *ptr, size_t nmemb, size_t size) |
| Allocate, reallocate, or free an array. More... | |
| int | av_reallocp_array (void *ptr, size_t nmemb, size_t size) |
| Allocate, reallocate, or free an array through a pointer to a pointer. More... | |
| void * | av_fast_realloc (void *ptr, unsigned int *size, size_t min_size) |
| Reallocate the given buffer if it is not large enough, otherwise do nothing. More... | |
| void | av_fast_malloc (void *ptr, unsigned int *size, size_t min_size) |
| Allocate a buffer, reusing the given one if large enough. More... | |
| void | av_fast_mallocz (void *ptr, unsigned int *size, size_t min_size) |
| Allocate and clear a buffer, reusing the given one if large enough. More... | |
| void | av_free (void *ptr) |
| Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family. More... | |
| void | av_freep (void *ptr) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family, and set the pointer pointing to it to NULL. More... | |
| char * | av_strdup (const char *s) av_malloc_attrib |
| Duplicate a string. More... | |
| char * | av_strndup (const char *s, size_t len) av_malloc_attrib |
| Duplicate a substring of a string. More... | |
| void * | av_memdup (const void *p, size_t size) |
| Duplicate a buffer with av_malloc(). More... | |
| void | av_memcpy_backptr (uint8_t *dst, int back, int cnt) |
| Overlapping memcpy() implementation. More... | |
Functions responsible for allocating, freeing, and copying memory.
All memory allocation functions have a built-in upper limit of INT_MAX bytes. This may be changed with av_max_alloc(), although exercise extreme caution when doing so.
| void* av_malloc | ( | size_t | size | ) |
Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU).
| size | Size in bytes for the memory block to be allocated |
NULL if the block cannot be allocated Referenced by decode_write(), and main().
| void* av_mallocz | ( | size_t | size | ) |
Allocate a memory block with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block.
| size | Size in bytes for the memory block to be allocated |
NULL if it cannot be allocated | void* av_malloc_array | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocate a memory block for an array with av_malloc().
The allocated memory will have size size * nmemb bytes.
| nmemb | Number of element |
| size | Size of a single element |
NULL if the block cannot be allocated Referenced by init_filters().
| void* av_mallocz_array | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocate a memory block for an array with av_mallocz().
The allocated memory will have size size * nmemb bytes.
| nmemb | Number of elements |
| size | Size of the single element |
NULL if the block cannot be allocatedReferenced by main(), and open_input_file().
| void* av_calloc | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Non-inlined equivalent of av_mallocz_array().
Created for symmetry with the calloc() C function.
| void* av_realloc | ( | void * | ptr, |
| size_t | size | ||
| ) |
Allocate, reallocate, or free 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. Otherwise, expand or shrink that block of memory according to size.
| ptr | Pointer to a memory block already allocated with av_realloc() or NULL |
| size | Size in bytes of the memory block to be allocated or reallocated |
NULL if the block cannot be reallocated or the function is used to free the memory block| av_warn_unused_result int av_reallocp | ( | void * | ptr, |
| size_t | size | ||
| ) |
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
If *ptr is NULL and size > 0, allocate a new block. If size is zero, free the memory block pointed to by *ptr. Otherwise, expand or shrink that block of memory according to size.
| [in,out] | ptr | Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure. |
| [in] | size | Size in bytes for the memory block to be allocated or reallocated |
| void* av_realloc_f | ( | void * | ptr, |
| size_t | nelem, | ||
| size_t | elsize | ||
| ) |
Allocate, reallocate, or free a block of memory.
This function does the same thing as av_realloc(), except:
nelem * elsize bytes, after checking the result of the multiplication for integer overflow.| void* av_realloc_array | ( | void * | ptr, |
| size_t | nmemb, | ||
| size_t | size | ||
| ) |
Allocate, reallocate, or free 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.
| ptr | Pointer to a memory block already allocated with av_realloc() or NULL |
| nmemb | Number of elements in the array |
| size | Size of the single element of the array |
| int av_reallocp_array | ( | void * | ptr, |
| size_t | nmemb, | ||
| size_t | size | ||
| ) |
Allocate, reallocate, or free 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.
| [in,out] | ptr | Pointer to a pointer to a memory block already allocated with av_realloc(), or a pointer to NULL. The pointer is updated on success, or freed on failure. |
| [in] | nmemb | Number of elements |
| [in] | size | Size of the single element |
| void* av_fast_realloc | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Reallocate the given buffer if it is not large enough, otherwise do nothing.
If the given buffer is NULL, then a new uninitialized buffer is allocated.
If the given buffer is not large enough, and reallocation fails, NULL is returned and *size is set to 0, but the original buffer is not changed or freed.
A typical use pattern follows:
| [in,out] | ptr | Already allocated buffer, or NULL |
| [in,out] | size | Pointer to the size of buffer ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer ptr |
ptr if the buffer is large enough, a pointer to newly reallocated buffer if the buffer was not large enough, or NULL in case of error | void av_fast_malloc | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Allocate a buffer, reusing the given one if large enough.
Contrary to av_fast_realloc(), the current buffer contents might not be preserved and on error the old buffer is freed, thus no special handling to avoid memleaks is necessary.
*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.
| [in,out] | ptr | Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure |
| [in,out] | size | Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer *ptr |
| void av_fast_mallocz | ( | void * | ptr, |
| unsigned int * | size, | ||
| size_t | min_size | ||
| ) |
Allocate and clear a buffer, reusing the given one if large enough.
Like av_fast_malloc(), but all newly allocated space is initially cleared. Reused buffer is not cleared.
*ptr is allowed to be NULL, in which case allocation always happens if size_needed is greater than 0.
| [in,out] | ptr | Pointer to pointer to an already allocated buffer. *ptr will be overwritten with pointer to new buffer on success or NULL on failure |
| [in,out] | size | Pointer to the size of buffer *ptr. *size is updated to the new allocated size, in particular 0 in case of failure. |
| [in] | min_size | Desired minimal size of buffer *ptr |
| void av_free | ( | void * | ptr | ) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family.
| ptr | Pointer to the memory block which should be freed. |
ptr = NULL is explicitly allowed. Referenced by main().
| void av_freep | ( | void * | ptr | ) |
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family, and set the pointer pointing to it to NULL.
| ptr | Pointer to the pointer to the memory block which should be freed |
*ptr = NULL is safe and leads to no action. Referenced by decode_write(), init_converted_samples(), main(), process_client(), and read_decode_convert_and_store().
| char* av_strdup | ( | const char * | s | ) |
Duplicate a string.
| s | String to be duplicated |
s or NULL if the string cannot be allocated Referenced by init_filter(), init_filters(), and open_output_file().
| char* av_strndup | ( | const char * | s, |
| size_t | len | ||
| ) |
Duplicate a substring of a string.
| s | String to be duplicated |
| len | Maximum length of the resulting string (not counting the terminating byte) |
s or NULL if the string cannot be allocated | void* av_memdup | ( | const void * | p, |
| size_t | size | ||
| ) |
Duplicate a buffer with av_malloc().
| p | Buffer to be duplicated |
| size | Size in bytes of the buffer copied |
p or NULL if the buffer cannot be allocated | void av_memcpy_backptr | ( | uint8_t * | dst, |
| int | back, | ||
| int | cnt | ||
| ) |
Overlapping memcpy() implementation.
| dst | Destination buffer |
| back | Number of bytes back to start copying (i.e. the initial size of the overlapping window); must be > 0 |
| cnt | Number of bytes to copy; must be >= 0 |
cnt > back is valid, this will copy the bytes we just copied, thus creating a repeating pattern with a period length of back.
1.8.13