treewide: cleanup malloc calls
[collectd.git] / src / email.c
index 81ae29c..8898c08 100644 (file)
@@ -219,7 +219,7 @@ static int email_config (const char *key, const char *value)
 static void type_list_incr (type_list_t *list, char *name, int incr)
 {
        if (NULL == list->head) {
-               list->head = (type_t *)smalloc (sizeof (type_t));
+               list->head = smalloc (sizeof (*list->head));
 
                list->head->name  = sstrdup (name);
                list->head->value = incr;
@@ -236,7 +236,7 @@ static void type_list_incr (type_list_t *list, char *name, int incr)
                }
 
                if (NULL == ptr) {
-                       list->tail->next = (type_t *)smalloc (sizeof (type_t));
+                       list->tail->next = smalloc (sizeof (*list->tail->next));
                        list->tail = list->tail->next;
 
                        list->tail->name  = sstrdup (name);
@@ -482,10 +482,10 @@ static void *open_connection (void __attribute__((unused)) *arg)
                available_collectors = max_conns;
 
                collectors =
-                       (collector_t **)smalloc (max_conns * sizeof (collector_t *));
+                       smalloc (max_conns * sizeof (*collectors));
 
                for (i = 0; i < max_conns; ++i) {
-                       collectors[i] = (collector_t *)smalloc (sizeof (collector_t));
+                       collectors[i] = smalloc (sizeof (*collectors[i]));
                        collectors[i]->socket = NULL;
 
                        if (0 != (err = plugin_thread_create (&collectors[i]->thread,
@@ -695,7 +695,7 @@ static void copy_type_list (type_list_t *l1, type_list_t *l2)
        for (ptr1 = l1->head, ptr2 = l2->head; NULL != ptr1;
                        ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
                if (NULL == ptr2) {
-                       ptr2 = (type_t *)smalloc (sizeof (type_t));
+                       ptr2 = smalloc (sizeof (*ptr2));
                        ptr2->name = NULL;
                        ptr2->next = NULL;