treewide: cleanup malloc calls
[collectd.git] / src / network.c
index 086f04e..ed382a0 100644 (file)
@@ -618,14 +618,14 @@ static int write_part_values (char **ret_buffer, int *ret_buffer_len,
        if (*ret_buffer_len < packet_len)
                return (-1);
 
-       pkg_values_types = (uint8_t *) malloc (num_values * sizeof (uint8_t));
+       pkg_values_types = malloc (num_values * sizeof (*pkg_values_types));
        if (pkg_values_types == NULL)
        {
                ERROR ("network plugin: write_part_values: malloc failed.");
                return (-1);
        }
 
-       pkg_values = (value_t *) malloc (num_values * sizeof (value_t));
+       pkg_values = malloc (num_values * sizeof (*pkg_values));
        if (pkg_values == NULL)
        {
                free (pkg_values_types);
@@ -2495,7 +2495,7 @@ static int network_receive (void) /* {{{ */
                         * these entries in the dispatch thread but put them in
                         * another list, so we don't have to allocate more and
                         * more of these structures. */
-                       ent = malloc (sizeof (receive_list_entry_t));
+                       ent = malloc (sizeof (*ent));
                        if (ent == NULL)
                        {
                                ERROR ("network plugin: malloc failed.");
@@ -2503,7 +2503,7 @@ static int network_receive (void) /* {{{ */
                                break;
                        }
                        memset (ent, 0, sizeof (receive_list_entry_t));
-                       ent->data = malloc (network_config_packet_size);
+                       ent->data = malloc (*ent->data);
                        if (ent->data == NULL)
                        {
                                sfree (ent);