dmi_alloc
Synopsis
#include <opendmi/utils.h>
void *dmi_alloc(dmi_context_t *context, size_t size);
void dmi_free(void *ptr);
Description
The dmi_alloc function allocates size bytes of memory, set to zero, the
way calloc(1, size) does. If the memory cannot be allocated, the failure is
reported on context.
The dmi_free function frees the memory ptr points to, the way free()
does, and does nothing if ptr is nullptr.
Memory allocated by dmi_alloc is freed with dmi_free or free(), and so
is memory the library allocates for the caller, e.g. the strings returned by
dmi_asprintf or dmi_date_format.
Return value
The dmi_alloc function returns a pointer to the allocated memory, or
nullptr if it cannot be allocated.
The dmi_free function returns no value.
Errors
DMI_ERROR_OUT_OF_MEMORY-
Raised by
dmi_alloconcontextif the memory cannot be allocated, unlesscontextisnullptr.
See also
calloc(3),
free(3),
dmi_error_get_last,
dmi_trace_out_of_memory