mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
Zero-initialize structs in init functions
Ensures there is no field left to its previous undefined value after calling an init function.
This commit is contained in:
parent
54653b5d95
commit
6c350799b2
20 changed files with 29 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/util/addon.h>
|
||||
|
||||
void wlr_addon_set_init(struct wlr_addon_set *set) {
|
||||
memset(set, 0, sizeof(*set));
|
||||
wl_list_init(&set->addons);
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +20,7 @@ void wlr_addon_set_finish(struct wlr_addon_set *set) {
|
|||
void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set,
|
||||
const void *owner, const struct wlr_addon_interface *impl) {
|
||||
assert(owner && impl);
|
||||
memset(addon, 0, sizeof(*addon));
|
||||
struct wlr_addon *iter;
|
||||
wl_list_for_each(iter, &set->addons, link) {
|
||||
if (iter->owner == addon->owner && iter->impl == addon->impl) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue