diff options
author | rbuj <[email protected]> | 2020-06-10 13:27:39 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-06-11 15:42:07 +0200 |
commit | fbb4a288d29950be3ae289df130a5ced15658ae8 (patch) | |
tree | ce546b6be03e5c6fbf08bd2a6cea2a053b5d5de8 | |
parent | cb3dfb26f1ae0f23f1e9ad67a35112ea171a1a90 (diff) | |
download | mate-sensors-applet-fbb4a288d29950be3ae289df130a5ced15658ae8.tar.bz2 mate-sensors-applet-fbb4a288d29950be3ae289df130a5ced15658ae8.tar.xz |
Replace g_malloc0 with g_new0 and g_strdup
-rw-r--r-- | lib/sensors-applet-plugin.c | 2 | ||||
-rw-r--r-- | plugins/libsensors/libsensors-plugin.c | 7 | ||||
-rw-r--r-- | plugins/udisks2/udisks2-plugin.c | 2 | ||||
-rw-r--r-- | sensors-applet/active-sensor.c | 4 |
4 files changed, 8 insertions, 7 deletions
diff --git a/lib/sensors-applet-plugin.c b/lib/sensors-applet-plugin.c index 96b47c6..acef5ef 100644 --- a/lib/sensors-applet-plugin.c +++ b/lib/sensors-applet-plugin.c @@ -132,7 +132,7 @@ void sensors_applet_plugin_add_sensor_with_limits(GList **sensors, SensorsAppletSensorInfo *info; - info = g_malloc0(sizeof(*info)); + info = g_new0 (SensorsAppletSensorInfo, 1); info->path = g_strdup(path); info->id = g_strdup(id); diff --git a/plugins/libsensors/libsensors-plugin.c b/plugins/libsensors/libsensors-plugin.c index 2dd18ae..5f1c096 100644 --- a/plugins/libsensors/libsensors-plugin.c +++ b/plugins/libsensors/libsensors-plugin.c @@ -83,10 +83,11 @@ static char *get_chip_name_string(const sensors_chip_name *chip) { #else /* adapted from lm-sensors:prog/sensors/main.c:sprintf_chip_name in lm-sensors-3.0 */ #define BUF_SIZE 200 - name = g_malloc0(BUF_SIZE); - if (sensors_snprintf_chip_name(name, BUF_SIZE, chip) < 0) { - g_free(name); + static char buf[BUF_SIZE]; + if (sensors_snprintf_chip_name(buf, BUF_SIZE, chip) < 0) { name = NULL; + } else { + name = g_strdup (buf); } #endif diff --git a/plugins/udisks2/udisks2-plugin.c b/plugins/udisks2/udisks2-plugin.c index ce648b1..f2e23c6 100644 --- a/plugins/udisks2/udisks2-plugin.c +++ b/plugins/udisks2/udisks2-plugin.c @@ -335,7 +335,7 @@ syslog(LOG_ERR, "Found udisks2 device temp: '%f'\n", temp); * save data */ if (smartenabled) { - info = g_malloc0 (sizeof (DevInfo)); + info = g_new0 (DevInfo, 1); if (NULL == devices) { devices = g_hash_table_new (g_str_hash, g_str_equal); } diff --git a/sensors-applet/active-sensor.c b/sensors-applet/active-sensor.c index 27619ac..7cf9df5 100644 --- a/sensors-applet/active-sensor.c +++ b/sensors-applet/active-sensor.c @@ -378,14 +378,14 @@ static void active_sensor_set_graph_dimensions(ActiveSensor *as, old_num_samples = as->num_samples; as->num_samples = num_samples; - as->sensor_values = g_malloc0(sizeof(gdouble)*as->num_samples); + as->sensor_values = g_new0 (gdouble, as->num_samples); memcpy(as->sensor_values, old_values, MIN(old_num_samples, as->num_samples)*sizeof(gdouble)); g_free(old_values); } else { - as->sensor_values = g_malloc0(sizeof(gdouble)*num_samples); + as->sensor_values = g_new0 (gdouble, num_samples); as->num_samples = num_samples; } |