mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
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:
@@ -27,7 +27,7 @@ static uint32_t getNumElements(const char* dirname, unsigned char type)
|
||||
|
||||
static uint32_t countBrewPackages(const char* dirname)
|
||||
{
|
||||
FFstrbuf baseDir;
|
||||
FF_STRBUF_AUTO_DESTROY baseDir;
|
||||
ffStrbufInitS(&baseDir, dirname);
|
||||
|
||||
uint32_t result = 0;
|
||||
@@ -41,7 +41,6 @@ static uint32_t countBrewPackages(const char* dirname)
|
||||
result += getNumElements(baseDir.chars, DT_DIR);
|
||||
ffStrbufSubstrBefore(&baseDir, baseDirLength);
|
||||
|
||||
ffStrbufDestroy(&baseDir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,14 +58,11 @@ static uint32_t getBrewPackages()
|
||||
|
||||
static uint32_t countMacPortsPackages(const char* dirname)
|
||||
{
|
||||
FFstrbuf baseDir;
|
||||
FF_STRBUF_AUTO_DESTROY baseDir;
|
||||
ffStrbufInitS(&baseDir, dirname);
|
||||
ffStrbufAppendS(&baseDir, "/var/macports/software");
|
||||
|
||||
uint32_t result = getNumElements(baseDir.chars, DT_DIR);
|
||||
|
||||
ffStrbufDestroy(&baseDir);
|
||||
return result;
|
||||
return getNumElements(baseDir.chars, DT_DIR);
|
||||
}
|
||||
|
||||
static uint32_t getMacPortsPackages()
|
||||
|
||||
Reference in New Issue
Block a user