Function libyml::api::yaml_realloc
source · pub unsafe fn yaml_realloc(ptr: *mut c_void, size: u64) -> *mut c_void
Expand description
Reallocate memory using the system’s realloc
function.
This function is a thin wrapper around the system’s realloc
function,
used for memory reallocation within the LibYML crate.
§Safety
- This function is unsafe because it directly calls the system’s
realloc
function, which can lead to undefined behaviour if misused. - The caller must ensure that the provided
ptr
is either a valid pointer returned by a previous call toyaml_malloc
oryaml_realloc
, or a null pointer. - The caller must ensure that the requested size is valid and does not overflow.
- If
realloc
fails to reallocate the memory, it returns a null pointer, and the original memory block pointed to byptr
is left unchanged. - The caller is responsible for properly freeing the reallocated memory using
the corresponding
yaml_free
function when it is no longer needed.