From 86ef9dcc028e1ca900a75fd810dc689bfba30627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 2 Nov 2020 19:04:32 +0100 Subject: [PATCH] =?UTF-8?q?particle/map:=20don=E2=80=99t=20return=20NULL?= =?UTF-8?q?=20from=20instantiate()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead return an empty dynlist. --- particles/map.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/particles/map.c b/particles/map.c index 6a65a72..57bb0fb 100644 --- a/particles/map.c +++ b/particles/map.c @@ -8,6 +8,7 @@ #include "../config-verify.h" #include "../particle.h" #include "../plugin.h" +#include "dynlist.h" struct particle_map { const char *tag_value; @@ -89,10 +90,9 @@ instantiate(const struct particle *particle, const struct tag_set *tags) const struct tag *tag = tag_for_name(tags, p->tag); if (tag == NULL) { - if (p->default_particle != NULL) - return p->default_particle->instantiate(p->default_particle, tags); - else - return NULL; + return p->default_particle != NULL + ? p->default_particle->instantiate(p->default_particle, tags) + : dynlist_exposable_new(NULL, 0, 0, 0); } const char *tag_value = tag->as_string(tag); @@ -108,13 +108,16 @@ instantiate(const struct particle *particle, const struct tag_set *tags) break; } - if (pp == NULL) { - assert(p->default_particle != NULL); - pp = p->default_particle; - } - struct eprivate *e = calloc(1, sizeof(*e)); - e->exposable = pp->instantiate(pp, tags); + + if (pp != NULL) + e->exposable = pp->instantiate(pp, tags); + else if (p->default_particle != NULL) + e->exposable = p->default_particle->instantiate(p->default_particle, tags); + else + e->exposable = dynlist_exposable_new(NULL, 0, 0, 0); + + assert(e->exposable != NULL); char *on_click = tags_expand_template(particle->on_click_template, tags); struct exposable *exposable = exposable_common_new(particle, on_click);