pmt: fix memory leaks, and improve info function

- Removed --no-write-test argument of memory test function
 - Fixed memory leak of memory test function
 - Improved info function with using nlohmann/json header-only library
 - Some other improvents
This commit is contained in:
2025-08-14 12:56:29 +03:00
parent bf0df8cc83
commit 563e8a583e
12 changed files with 25795 additions and 48 deletions

View File

@@ -81,14 +81,14 @@ private:
std::vector<uint8_t *> _ptrs_u;
std::vector<FILE *> _fps;
std::vector<int> _fds;
std::vector<std::string_view> _files;
std::vector<std::string> _files;
public:
~garbageCollector();
void delAfterProgress(char *&_ptr);
void delAfterProgress(uint8_t *&_ptr);
void delFileAfterProgress(std::string_view path);
void delFileAfterProgress(const std::string& path);
void closeAfterProgress(FILE *&_fp);
void closeAfterProgress(int _fd);
};

View File

@@ -95,7 +95,7 @@ garbageCollector::~garbageCollector() {
close(fd);
for (const auto &fp : _fps)
fclose(fp);
for (const auto &file: _files)
for (const auto &file : _files)
eraseEntry(file);
}
@@ -105,7 +105,7 @@ void garbageCollector::delAfterProgress(char *&_ptr) {
void garbageCollector::delAfterProgress(uint8_t *&_ptr) {
_ptrs_u.push_back(_ptr);
}
void garbageCollector::delFileAfterProgress(const std::string_view path) {
void garbageCollector::delFileAfterProgress(const std::string &path) {
_files.push_back(path);
}
void garbageCollector::closeAfterProgress(const int _fd) {

View File

@@ -118,6 +118,7 @@ public:
[[nodiscard]] constant_iterator cend() const;
};
using Partition_t = _entry;
using Map_t = basic_partition_map;
class basic_partition_map_builder final {

View File

@@ -47,7 +47,7 @@ bool basic_partition_map_builder::_is_real_block_dir(
}
Map_t basic_partition_map_builder::_build_map(std::string_view path,
bool logical) {
const bool logical) {
Map_t map;
std::vector<std::filesystem::directory_entry> entries{
std::filesystem::directory_iterator(path),