Next: handlers init func clean, Previous: handlers init macro clean, Up: handlers init [Contents][Index]
All the following definitions are accessible from the header file ccexceptions.h.
Initialise the error handler referenced by H with the given handler function and resource
pointer; the argument RESOURCE_POINTER can be NULL.
Upon exiting the associated location context: the handler might finalise the resource referenced by RESOURCE_POINTER, but it can also perform some unrelated operations.
Initialise the error handler referenced by H with the given handler function, resource pointer
and resource destructor; the arguments RESOURCE_POINTER and RESOURCE_DESTRUCTOR can be
NULL.
Upon exiting the associated location context: the handler might finalise the resource referenced by RESOURCE_POINTER using the destructor function referenced by RESOURCE_DESTRUCTOR, but it can also perform some unrelated operations.
As example of initialising a error handler:
void
error_handler (cce_condition_t const * C, cce_error_handler_t const * P_H)
{
free(cce_handler_resource_pointer(P_H));
}
void
main (void)
{
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_malloc(L, 4096);
cce_init_handler(P_H, error_handler, cce_resource_pointer(P));
cce_register_handler(L, P_H);
/* Do something with "P". */
cce_run_body_handlers(L);
}
}
As example of initialising a error handler using a destructor function:
void
error_handler (cce_condition_t const * C, cce_error_handler_t const * P_H)
{
cce_resource_destructor_fun_t * release;
release = cce_handler_resource_destructor(P_H);
release(cce_handler_resource_pointer(P_H));
}
void
main (void)
{
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_malloc(L, 4096);
cce_init_handler(P_H, error_handler, cce_resource_pointer(P), free);
cce_register_handler(L, P_H);
/* Do something with "P". */
cce_run_body_handlers(L);
}
}
As example of initialising a error handler using a destructor function and the built–in handler function:
void
main (void)
{
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_malloc(L, 4096);
cce_init_handler(P_H, cce_default_error_handler_function,
cce_resource_pointer(P), free);
cce_register_handler(L, P_H);
/* Do something with "P". */
cce_run_body_handlers(L);
}
}
Next: handlers init func clean, Previous: handlers init macro clean, Up: handlers init [Contents][Index]
This document describes version 0.9.0-devel.3 of CCExceptions.