aboutsummaryrefslogtreecommitdiff
path: root/getcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'getcore.c')
-rw-r--r--getcore.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/getcore.c b/getcore.c
index 51ac0e4..3014db0 100644
--- a/getcore.c
+++ b/getcore.c
@@ -33,12 +33,13 @@ unsigned int cores;
**********************************************************************/
bool core_exists(unsigned int core)
{
- FILE* fd;
- char path[128];
-
- sprintf(path, "/sys/devices/system/cpu/cpu%d/cpufreq", core);
+ char* path;
+ int result;
+ asprintf(&path, "/sys/devices/system/cpu/cpu%d/cpufreq", core);
debug("Checking if core %d exists by opening '%s'\n",core,path);
- return (access(path, F_OK) != -1);
+ result = access(path, F_OK);
+ free (path);
+ return (result != -1);
}