libhelper: improve garbageCollector
This commit is contained in:
@@ -19,15 +19,11 @@
|
||||
|
||||
#include <libhelper/lib.hpp>
|
||||
#include <libpartition_map/lib.hpp>
|
||||
#include <CLI/CLI11.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#include <CLI/CLI11.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#define PMT "libpmt"
|
||||
#define PMTE "pmt"
|
||||
#define PMTF "libpmt-function-manager"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#ifndef ONLY_HELPER_MACROS
|
||||
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
|
||||
void delAfterProgress(char *&_ptr);
|
||||
void delAfterProgress(uint8_t *&_ptr);
|
||||
void delAfterProgress(FILE *&_fp);
|
||||
void closeAfterProgress(FILE *&_fp);
|
||||
void closeAfterProgress(int _fd);
|
||||
};
|
||||
|
||||
|
||||
@@ -106,5 +106,5 @@ void garbageCollector::delAfterProgress(uint8_t *&_ptr) {
|
||||
void garbageCollector::closeAfterProgress(const int _fd) {
|
||||
_fds.push_back(_fd);
|
||||
}
|
||||
void garbageCollector::delAfterProgress(FILE *&_fp) { _fps.push_back(_fp); }
|
||||
void garbageCollector::closeAfterProgress(FILE *&_fp) { _fps.push_back(_fp); }
|
||||
} // namespace Helper
|
||||
|
||||
@@ -194,7 +194,7 @@ int openAndAddToCloseList(const std::string_view &path,
|
||||
FILE *openAndAddToCloseList(const std::string_view &path,
|
||||
garbageCollector &collector, const char *mode) {
|
||||
FILE *fp = fopen(path.data(), mode);
|
||||
collector.delAfterProgress(fp);
|
||||
collector.closeAfterProgress(fp);
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user