Next: , Previous: , Up: system memory   [Contents][Index]


7.1.2 Handlers for allocated memory

We can handle memory that must be released with the standard function free() as follows:

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_malloc(L, 4096);
  cce_init_and_register_handler_malloc(L, P_H, P);
  cce_run_body_handlers(L);
}
Function: void cce_init_and_register_clean_handler_malloc (cce_destination_t L, cce_clean_handler_t * H, void * P)

Register H as handler in the context of L. The handler function will release the memory block referenced by P using the standard function free().

Function: void cce_init_and_register_error_handler_malloc (cce_destination_t L, cce_error_handler_t * H, void * P)

Register H as handler in the context of L. The handler function will release the memory block referenced by P using the standard function free().

Preprocessor Macro: void cce_init_and_register_handler_malloc (cce_destination_t L, cce_clean_handler_t * P_H, void * P)
Preprocessor Macro: void cce_init_and_register_handler_malloc (cce_destination_t L, cce_error_handler_t * P_H, void * P)

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_t

The macro expands into a call to cce_init_and_register_clean_handler_malloc().

cce_error_handler_t

The macro expands into a call to cce_init_and_register_error_handler_malloc().


Next: , Previous: , Up: system memory   [Contents][Index]

This document describes version 0.9.0-devel.3 of CCExceptions.