X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmeta_data.c;h=b6483e8bf77681fbd798b319f282fccd1510f583;hb=36d4680ddbd5629badccb4448d053190ac5a3175;hp=ea98ba94abf44670583ab47601e39ce6a0f68394;hpb=b22ffd9cb1938b4931d7628420a9f0b50461333f;p=collectd.git diff --git a/src/meta_data.c b/src/meta_data.c index ea98ba94..b6483e8b 100644 --- a/src/meta_data.c +++ b/src/meta_data.c @@ -250,7 +250,6 @@ void meta_data_destroy (meta_data_t *md) /* {{{ */ if (md == NULL) return; - pthread_mutex_destroy(&md->lock); md_entry_free (md->head); pthread_mutex_destroy (&md->lock); free (md); @@ -313,7 +312,13 @@ int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */ for (e = md->head; e != NULL; e = e->next) ++count; - *toc = malloc(count * sizeof(**toc)); + if (count == 0) + { + pthread_mutex_unlock (&md->lock); + return (count); + } + + *toc = calloc(count, sizeof(**toc)); for (e = md->head; e != NULL; e = e->next) (*toc)[i++] = strdup(e->key); @@ -483,7 +488,7 @@ int meta_data_get_string (meta_data_t *md, /* {{{ */ if (e->type != MD_TYPE_STRING) { - ERROR ("meta_data_get_signed_int: Type mismatch for key `%s'", e->key); + ERROR ("meta_data_get_string: Type mismatch for key `%s'", e->key); pthread_mutex_unlock (&md->lock); return (-ENOENT); }