예제 #1
0
    long long ReadCpuCGroupValue(const char* subsystemFilename){
        char *filename = nullptr;
        bool result = false;
        long long val;

        if (m_cpu_cgroup_path == nullptr)
            return -1;

        filename = (char*)malloc(strlen(m_cpu_cgroup_path) + strlen(subsystemFilename) + 1);
        if (filename == nullptr)
            return -1;

        strcpy(filename, m_cpu_cgroup_path);
        strcat(filename, subsystemFilename);
        result = ReadLongLongValueFromFile(filename, &val);
        free(filename);
        if (!result)
             return -1;

        return val;
    }
예제 #2
0
    static long long ReadCpuCGroupValue(const char* subsystemFilename){
        char *filename = nullptr;
        bool result = false;
        long long val;
        size_t len;

        if (s_cpu_cgroup_path == nullptr)
            return -1;

        len = strlen(s_cpu_cgroup_path);
        len += strlen(subsystemFilename);
        filename = (char*)PAL_malloc(len + 1);
        if (filename == nullptr)
            return -1;

        strcpy_s(filename, len+1, s_cpu_cgroup_path);
        strcat_s(filename, len+1, subsystemFilename);
        result = ReadLongLongValueFromFile(filename, &val);
        PAL_free(filename);
        if (!result)
            return -1;

        return val;
    }