mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-21 19:51:45 +00:00
libsensors: New method to free the memory allocated for the internal
representation of chip names. sensord, sensors: Fix a memory leak when one or more chip names are provided on the command line. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5740 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
ef2f2c04ce
commit
78f496ca62
9 files changed
+44
-4
No files matched your search
@@ -54,6 +54,11 @@ sensors_bus *sensors_proc_bus = NULL;
|
||||
int sensors_proc_bus_count = 0;
|
||||
int sensors_proc_bus_max = 0;
|
||||
|
||||
void sensors_free_chip_name(sensors_chip_name *chip)
|
||||
{
|
||||
free(chip->prefix);
|
||||
}
|
||||
|
||||
/*
|
||||
Parse a chip name to the internal representation. These are valid names:
|
||||
|
||||
|
||||
+9
-1
@@ -42,6 +42,7 @@ libsensors \- publicly accessible functions provided by the sensors library
|
||||
/* Chip name handling */
|
||||
.BI "int sensors_parse_chip_name(const char *" orig_name ","
|
||||
.BI " sensors_chip_name *" res ");"
|
||||
.BI "void sensors_free_chip_name(sensors_chip_name *" chip ");"
|
||||
.BI "int sensors_snprintf_chip_name(char *" str ", size_t " size ","
|
||||
.BI " const sensors_chip_name *" chip ");"
|
||||
.BI "const char *sensors_get_adapter_name(const sensors_bus_id *" bus ");"
|
||||
@@ -101,7 +102,14 @@ is a string representing the version of libsensors.
|
||||
|
||||
.B sensors_parse_chip_name()
|
||||
parses a chip name to the internal representation. Return 0 on success,
|
||||
<0 on error.
|
||||
<0 on error. Make sure to call sensors_free_chip_name() when you're done
|
||||
with the data.
|
||||
|
||||
.B sensors_free_chip_name()
|
||||
frees the memory that may have been allocated for the internal
|
||||
representation of a chip name. You only have to call this for chip
|
||||
names which do not originate from libsensors itself (that is, chip
|
||||
names which were generated by sensors_parse_chip_name()).
|
||||
|
||||
.B sensors_snprintf_chip_name()
|
||||
prints a chip name from its internal representation. Note that chip should
|
||||
|
||||
+4
-1
@@ -31,7 +31,7 @@
|
||||
when the API + ABI breaks), the third digit is incremented to track small
|
||||
API additions like new flags / enum values. The second digit is for tracking
|
||||
larger additions like new methods. */
|
||||
#define SENSORS_API_VERSION 0x410
|
||||
#define SENSORS_API_VERSION 0x420
|
||||
|
||||
#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
|
||||
#define SENSORS_CHIP_NAME_ADDR_ANY (-1)
|
||||
@@ -80,6 +80,9 @@ void sensors_cleanup(void);
|
||||
on error. */
|
||||
int sensors_parse_chip_name(const char *orig_name, sensors_chip_name *res);
|
||||
|
||||
/* Free memory allocated for the internal representation of a chip name. */
|
||||
void sensors_free_chip_name(sensors_chip_name *chip);
|
||||
|
||||
/* Print a chip name from its internal representation. Note that chip should
|
||||
not contain wildcard values! Return the number of characters printed on
|
||||
success (same as snprintf), <0 on error. */
|
||||
|
||||
Reference in new issue
Block a user