From 55a2bfcc295a1cccc749a3ef15a70608c2699e88 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 6 Nov 2023 19:09:00 +0200 Subject: [PATCH] used existing empty place in vector when allocate a new one --- src/core/file_sys/fs.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index 29c35179..7bf81178 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -40,7 +40,14 @@ int HandleTable::createHandle() { file->isOpened = false; int existingFilesNum = m_files.size(); - // TODO when i close a file m_files probably have a open pos , so we can fill this + + for (int index = 0; index < existingFilesNum; index++) { + if (m_files.at(index) == nullptr) { + m_files[index] = file; + return index; + } + } + m_files.push_back(file); return existingFilesNum - 1;