X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=secchan%2Fstatus.c;h=8b6224c4636641de8059600b1d6a8343ce5b9cb4;hb=c3a7107e9ef6d4c744c86b239042a20f58f81a9b;hp=c1e54943ed3f0f8f2e559e17d14fa78a31ae8095;hpb=92500deb632bf8ab869630eed4a1a852cc8302d5;p=sliver-openvswitch.git diff --git a/secchan/status.c b/secchan/status.c index c1e54943e..8b6224c46 100644 --- a/secchan/status.c +++ b/secchan/status.c @@ -57,8 +57,8 @@ struct switch_status_category { struct switch_status { const struct settings *s; time_t booted; - struct switch_status_category categories[8]; - int n_categories; + struct switch_status_category *categories; + int n_categories, allocated_categories; }; struct status_reply { @@ -190,12 +190,16 @@ switch_status_start(struct secchan *secchan, const struct settings *s, void switch_status_register_category(struct switch_status *ss, const char *category, - void (*cb)(struct status_reply *, - void *aux), + void (*cb)(struct status_reply *, void *aux), void *aux) { struct switch_status_category *c; - assert(ss->n_categories < ARRAY_SIZE(ss->categories)); + if (ss->n_categories >= ss->allocated_categories) { + ss->allocated_categories = 1 + ss->allocated_categories * 2; + ss->categories = xrealloc(ss->categories, + (sizeof *ss->categories + * ss->allocated_categories)); + } c = &ss->categories[ss->n_categories++]; c->cb = cb; c->aux = aux;