Next: system memory grealloc, Previous: system memory gmalloc, Up: system memory [Contents][Index]
calloc()To allocate memory using a clean handler with a guarded function, we can do:
cce_location_t L[1];
cce_clean_handler_t P_H[1];
if (cce_location(L)) {
cce_run_catch_handlers_final(L);
} else {
void * P = cce_sys_calloc_guarded(L, P_H, 4, 1024);
/* Do something with P. */
cce_run_body_handlers(L);
}
while to use an error handler we can do:
cce_location_t L[1];
cce_error_handler_t P_H[1];
if (cce_location(L)) {
cce_run_catch_handlers_final(L);
} else {
void * P = cce_sys_calloc_guarded(L, P_H, 4, 1024);
/* Do something with P. */
cce_run_body_handlers(L);
}
Like cce_sys_calloc(), but register the resulting pointer in the handler referenced by
P_H.
This preprocessor macro uses _Generic to dispatch the call according to the type of the
pointer P_H; if the type is:
cce_clean_handler_tThe macro expands into a call to cce_sys_calloc_guarded_clean().
cce_error_handler_tThe macro expands into a call to cce_sys_calloc_guarded_error().
Next: system memory grealloc, Previous: system memory gmalloc, Up: system memory [Contents][Index]
This document describes version 0.9.0-devel.3 of CCExceptions.