For data that lives the life of the server, this provides a quick way to create and forget about freeing them. More...
#include "qev.h"Go to the source code of this file.
Functions | |
| void | qev_cleanup (void *ptr, const qev_free_fn free_fn) |
| Calls qev_cleanup() with last=FALSE. | |
| void | qev_cleanup_full (void *ptr, const qev_free_fn free_fn, const gboolean last) |
| Adds a pointer to a thread-local that needs to be cleaned up on exit. More... | |
| void | qev_cleanup_and_null (void **ptrptr, const qev_free_fn free_fn) |
| Calls qev_cleanup_and_null_full() with last=FALSE. | |
| void | qev_cleanup_and_null_full (void **ptrptr, const qev_free_fn free_fn, const gboolean last) |
| Adds a pointer to be cleaned up and set to NULL on exit. More... | |
| void | qev_cleanup_fn (const qev_cb fn) |
| Calls qev_cleanup_fn_full() with last=FALSE. | |
| void | qev_cleanup_fn_full (const qev_cb cb, const gboolean last) |
| Adds a simple function to be called on exit. More... | |
For data that lives the life of the server, this provides a quick way to create and forget about freeing them.
On server exit, all registered pointers will have their free functions called and their original pointers will be nulled out.
The cleanup functions are called in the reverse of the order they were added; that is, most-recently added is called first. Since programs typically boot by starting dependencies first, it only makes sense to tear down what nothing depends on while leaving the dependencies until last to make sure everything exits smoothly.
| void qev_cleanup_and_null_full | ( | void ** | ptrptr, |
| const qev_free_fn | free_fn, | ||
| const gboolean | last | ||
| ) |
Adds a pointer to be cleaned up and set to NULL on exit.
| ptrptr | A pointer to the pointer to be cleared out and null'd on exit. |
| free_fn | The function to free the pointer on exit. |
| last | If the item should be freed after everything else. This is useful for things that must last the life of the server and are used during shutdown. |
| void qev_cleanup_fn_full | ( | const qev_cb | cb, |
| const gboolean | last | ||
| ) |
Adds a simple function to be called on exit.
| cb | The function to call on exit |
| last | If the function should be called after everything else |
| void qev_cleanup_full | ( | void * | ptr, |
| const qev_free_fn | free_fn, | ||
| const gboolean | last | ||
| ) |
Adds a pointer to a thread-local that needs to be cleaned up on exit.
| ptr | The pointer to pass to the free function on exit. |
| free_fn | The function to free the pointer on exit. |
| last | If the item should be freed after everything else. This is useful for things that must last the life of the server and are used during shutdown. |
1.8.6