From fbb4a288d29950be3ae289df130a5ced15658ae8 Mon Sep 17 00:00:00 2001 From: rbuj Date: Wed, 10 Jun 2020 13:27:39 +0200 Subject: Replace g_malloc0 with g_new0 and g_strdup --- plugins/libsensors/libsensors-plugin.c | 7 ++++--- plugins/udisks2/udisks2-plugin.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins') 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); } -- cgit v1.2.1