aboutsummaryrefslogtreecommitdiff
path: root/getgov.c
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-09-01 19:19:24 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-09-01 19:19:24 +1200
commitdec1efba06aeadcd9a4f13e8591f2efa016a24a0 (patch)
tree1293bc4cf8bc8a5acd3f9aef5fbc7215f3689983 /getgov.c
parent93b76533735fc1d9fd666787acd65db8507d9119 (diff)
downloadparamano-dec1efba06aeadcd9a4f13e8591f2efa016a24a0.tar.xz
Replace asprintf calls with snprintf
Diffstat (limited to 'getgov.c')
-rw-r--r--getgov.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/getgov.c b/getgov.c
index e86f7fd..7ff8562 100644
--- a/getgov.c
+++ b/getgov.c
@@ -57,14 +57,11 @@ void gg_init()
bool gg_current(int core, char* out, int size)
{
FILE* fd;
- char *path;
- asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", core);
+ char path[1024];
+ snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", core);
if (!(fd = fopen(path, "r")))
- {
- free(path);
return false;
- }
fgets(out, size, fd);
@@ -73,7 +70,6 @@ bool gg_current(int core, char* out, int size)
*newline = '\0';
fclose(fd);
- free(path);
return true;
}
@@ -83,18 +79,15 @@ bool gg_current(int core, char* out, int size)
**********************************************************************/
bool gg_available(int core, char* out, int size)
{
- char *path;
+ char path[1024];
FILE *fd;
- asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors", core);
+ snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_available_governors", core);
if (!(fd = fopen(path, "r")))
- {
- free(path);
return false;
- }
+
fgets(out, size, fd);
fclose(fd);
- free(path);
return true;
}