pmt: add memory test function and some new functions to libhelper

This commit is contained in:
2025-08-13 10:58:48 +03:00
parent 0bc5f70294
commit bf0df8cc83
7 changed files with 33 additions and 13 deletions

View File

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

View File

@@ -216,5 +216,11 @@ bool reboot(const std::string_view arg) {
return android_reboot(cmd, 0, arg.empty() ? nullptr : arg.data()) != -1;
}
uint64_t getRandomOffset(const uint64_t size, const uint64_t bufferSize) {
if (size <= bufferSize) return 0;
const uint64_t maxOffset = size - bufferSize;
return rand() % maxOffset;
}
std::string getLibVersion() { MKVERSION("libhelper"); }
} // namespace Helper