Windows / macOS: simplify code

1. simplify resource management by using C++ RAII like GCC attribute extension `cleanup`
2. simplify HEKY reading

Actually `__attribute__((__cleanup__(cleanupFn)))` is supported on all major C compiler ( gcc, clang and icc ) except MSVC I only used it on Windows and macOS for now. Let's see if the project author like it.
This commit is contained in:
李通洲 committed 2022-11-17 19:54:36 +08:00
1 parent fb78d9bbb9
commit e8e586ce7c
12 files changed
+72 -75

No files matched your search

+1 -2
View File
@@ -8,7 +8,7 @@
static double detectGpuTemp(const FFstrbuf* gpuName)
{
FFlist temps;
FF_LIST_AUTO_DESTROY temps;
ffListInit(&temps, sizeof(FFTempValue));
if(ffStrbufStartsWithS(gpuName, "Apple M1"))
@@ -35,7 +35,6 @@ static double detectGpuTemp(const FFstrbuf* gpuName)
ffStrbufDestroy(&tempValue->deviceClass);
}
result /= temps.length;
ffListDestroy(&temps);
return result;
}