Function rsmpeg::ffi::av_freep[][src]

pub unsafe extern "C" fn av_freep(ptr: *mut c_void)
Expand description

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.

@code{.c} uint8_t *buf = av_malloc(16); av_free(buf); // buf now contains a dangling pointer to freed memory, and accidental // dereference of buf will result in a use-after-free, which may be a // security risk.

uint8_t *buf = av_malloc(16); av_freep(&buf); // buf is now NULL, and accidental dereference will only result in a // NULL-pointer dereference. @endcode

@param ptr Pointer to the pointer to the memory block which should be freed @note *ptr = NULL is safe and leads to no action. @see av_free()