pmt: add memory test function and some new functions to libhelper
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user