X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmeta_data.c;h=6a336c4b67c734b62cf1516c3375b649fd826cac;hb=53181fa3b5a91f47e51d01d56b34906f8b244a1b;hp=a7c11c10607352d9cbf0a938a185a54895bfd970;hpb=9c52b4ff1590251ea5fcefab15c0af655d49624c;p=collectd.git diff --git a/src/meta_data.c b/src/meta_data.c index a7c11c10..6a336c4b 100644 --- a/src/meta_data.c +++ b/src/meta_data.c @@ -245,7 +245,7 @@ int meta_data_type (meta_data_t *md, const char *key) /* {{{ */ meta_entry_t *e; if ((md == NULL) || (key == NULL)) - return 0; + return -EINVAL; pthread_mutex_lock (&md->lock); @@ -262,6 +262,27 @@ int meta_data_type (meta_data_t *md, const char *key) /* {{{ */ return 0; } /* }}} int meta_data_type */ +int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */ +{ + int i = 0, count = 0; + meta_entry_t *e; + + if ((md == NULL) || (toc == NULL)) + return -EINVAL; + + pthread_mutex_lock (&md->lock); + + for (e = md->head; e != NULL; e = e->next) + ++count; + + *toc = malloc(count * sizeof(**toc)); + for (e = md->head; e != NULL; e = e->next) + (*toc)[i++] = strdup(e->key); + + pthread_mutex_unlock (&md->lock); + return count; +} /* }}} int meta_data_toc */ + int meta_data_delete (meta_data_t *md, const char *key) /* {{{ */ { meta_entry_t *this;