projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1611 from stefanth/Collection3/graph-rendering-speedup
[collectd.git]
/
src
/
daemon
/
meta_data.c
diff --git
a/src/daemon/meta_data.c
b/src/daemon/meta_data.c
index
d3da9bb
..
f87e35e
100644
(file)
--- a/
src/daemon/meta_data.c
+++ b/
src/daemon/meta_data.c
@@
-71,7
+71,7
@@
static char *md_strdup (const char *orig) /* {{{ */
return (NULL);
sz = strlen (orig) + 1;
return (NULL);
sz = strlen (orig) + 1;
- dest =
(char *)
malloc (sz);
+ dest = malloc (sz);
if (dest == NULL)
return (NULL);
if (dest == NULL)
return (NULL);
@@
-84,13
+84,12
@@
static meta_entry_t *md_entry_alloc (const char *key) /* {{{ */
{
meta_entry_t *e;
{
meta_entry_t *e;
- e =
(meta_entry_t *) malloc (
sizeof (*e));
+ e =
calloc (1,
sizeof (*e));
if (e == NULL)
{
if (e == NULL)
{
- ERROR ("md_entry_alloc:
m
alloc failed.");
+ ERROR ("md_entry_alloc:
c
alloc failed.");
return (NULL);
}
return (NULL);
}
- memset (e, 0, sizeof (*e));
e->key = md_strdup (key);
if (e->key == NULL)
e->key = md_strdup (key);
if (e->key == NULL)
@@
-114,6
+113,8
@@
static meta_entry_t *md_entry_clone (const meta_entry_t *orig) /* {{{ */
return (NULL);
copy = md_entry_alloc (orig->key);
return (NULL);
copy = md_entry_alloc (orig->key);
+ if (copy == NULL)
+ return (NULL);
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup (orig->value.mv_string);
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup (orig->value.mv_string);
@@
-218,15
+219,13
@@
meta_data_t *meta_data_create (void) /* {{{ */
{
meta_data_t *md;
{
meta_data_t *md;
- md =
(meta_data_t *) malloc (
sizeof (*md));
+ md =
calloc (1,
sizeof (*md));
if (md == NULL)
{
if (md == NULL)
{
- ERROR ("meta_data_create:
m
alloc failed.");
+ ERROR ("meta_data_create:
c
alloc failed.");
return (NULL);
}
return (NULL);
}
- memset (md, 0, sizeof (*md));
- md->head = NULL;
pthread_mutex_init (&md->lock, /* attr = */ NULL);
return (md);
pthread_mutex_init (&md->lock, /* attr = */ NULL);
return (md);
@@
-255,7
+254,6
@@
void meta_data_destroy (meta_data_t *md) /* {{{ */
if (md == NULL)
return;
if (md == NULL)
return;
- pthread_mutex_destroy(&md->lock);
md_entry_free (md->head);
pthread_mutex_destroy (&md->lock);
free (md);
md_entry_free (md->head);
pthread_mutex_destroy (&md->lock);
free (md);
@@
-316,7
+314,7
@@
int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */
pthread_mutex_lock (&md->lock);
for (e = md->head; e != NULL; e = e->next)
pthread_mutex_lock (&md->lock);
for (e = md->head; e != NULL; e = e->next)
- ++count;
+ ++count;
if (count == 0)
{
if (count == 0)
{
@@
-327,7
+325,7
@@
int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */
*toc = calloc(count, sizeof(**toc));
for (e = md->head; e != NULL; e = e->next)
(*toc)[i++] = strdup(e->key);
*toc = calloc(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 */
pthread_mutex_unlock (&md->lock);
return count;
} /* }}} int meta_data_toc */
@@
-494,7
+492,7
@@
int meta_data_get_string (meta_data_t *md, /* {{{ */
if (e->type != MD_TYPE_STRING)
{
if (e->type != MD_TYPE_STRING)
{
- ERROR ("meta_data_get_s
igned_int
: Type mismatch for key `%s'", e->key);
+ ERROR ("meta_data_get_s
tring
: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock (&md->lock);
return (-ENOENT);
}
pthread_mutex_unlock (&md->lock);
return (-ENOENT);
}
@@
-506,7
+504,7
@@
int meta_data_get_string (meta_data_t *md, /* {{{ */
ERROR ("meta_data_get_string: md_strdup failed.");
return (-ENOMEM);
}
ERROR ("meta_data_get_string: md_strdup failed.");
return (-ENOMEM);
}
-
+
pthread_mutex_unlock (&md->lock);
*value = temp;
pthread_mutex_unlock (&md->lock);
*value = temp;