|
NAMEsf_malloc , sf_calloc ,
sf_realloc , sf_strdup ,
strndup , strfunc_ctl —
string duplication and safe memory allocation.
SYNOPSIS#include <strfunc.h>
Safe
malloc(3)
analog:
Safe
calloc(3)
analog:
Safe
realloc(3)
analog:
Duplicate a specified number of characters from the string:
Safe
strdup(3)
analog:
DESCRIPTIONThose functions are used internally by virtually alllibstrfunc functions to manipulate memory. They are
wrappers around the native library calls
malloc(3),
calloc(3),
realloc(3)
and provide additional flexibility in those cases when system is low in
memory.
All functions are defaulted to call
abort(3)
upon the unsatisfied memory request. This default behavior can be easily
changed by using int
The request argument can be the following constant: SF_GET_MEMORY_FAILURE_BEHAVIOR SF_SET_MEMORY_FAILURE_BEHAVIOR SF_GET_MEMORY_FAILURE_TRIES SF_SET_MEMORY_FAILURE_TRIES to get or set the memory allocation behaviour appropriately. While the third and fourth values are used to get or specify the number of tries of allocating resources before falling into a failure case, the first two values can be used to switch the default behaviour to call abort(3) in case of failure. SF_GET_MEMORY_FAILURE_BEHAVIOR returns with and SF_SET_MEMORY_FAILURE_BEHAVIOR accept the following values: SF_ARG_MFB_ABORT /* call abort(3) on failure, the default */ SF_ARG_MFB_ENOMEM /* return NULL with errno set to ENOMEM */ SF_ARG_MFB_TRY_ABORT /* try N times before calling abort(3) */ SF_ARG_MFB_TRY_ENOMEM /* do the same before returning an error */ SF_ARG_MFB_TRY_NOFAIL /* loop indefinitely */ Again, virually all functions defined in
int memory_control_type = SF_ARG_MFB_TRY_NOFAIL; strfunc_ctl(SF_SET_MEMORY_FAILURE_BEHAVIOR, &memory_control_type); SEE ALSOstrfunc(3), malloc(3).AUTHORSLev Walkin <vlm@lionet.info>
Visit the GSP FreeBSD Man Page Interface. |