CONTRIBUTING.md: mention listener list assertions

This commit is contained in:
Kirill Primak 2025-01-20 16:17:12 +03:00
parent b25f98d583
commit 980ac9e4c8

View file

@ -213,6 +213,27 @@ reinitialized to be used again.
it, and free the memory. Such functions should always be able to accept a NULL it, and free the memory. Such functions should always be able to accept a NULL
pointer. pointer.
If the object has signals, the destructor function must assert that their
listener lists are empty.
```c
void wlr_thing_init(struct wlr_thing *thing) {
*thing = (struct wlr_thing){
// ...
};
wl_signal_init(&thing->events.destroy);
wl_signal_init(&thing->events.foo);
}
void wlr_thing_finish(struct wlr_thing *thing) {
wl_signal_emit_mutable(&thing->events.destroy, NULL);
assert(wl_list_empty(&thing->events.destroy.listener_list));
assert(wl_list_empty(&thing->events.foo.listener_list));
}
```
### Error Codes ### Error Codes
For functions not returning a value, they should return a (stdbool.h) bool to For functions not returning a value, they should return a (stdbool.h) bool to