To keep Ion's code as simple as possible yet safe, there are restrictions when the WObj destroy_obj function that calls watches, the deinit routine and frees memory may be called directly. In all other cases the mainloop_defer_destroy function should be used to defer the call of destroy_obj until Ioncore returns to its main event loop.
Calling the destroy_obj function directly is allowed in the following cases:
If there are no serious side effects from deferring destroying the object or you're unsure whether it is safe to destroy the object immediately, use mainloop_defer_destroy.
The following rules should apply to using strings as return values and parameters to functions.
Type | Return value | Parameter |
const char* | The string is owned by the called function and the caller is only quaranteed short-term read access to the string. | The called function may only read the string during its execution. For further reference a copy must be made. |
char* | The string is the caller's responsibility and it must free it when no longer needed. | The called function may modify the string but the ``owner'' of the string is case-dependant. |