Proper fragmentation handling

This commit is contained in:
Phillip Stephens 2016-06-26 10:34:45 -07:00
parent fe835efd71
commit aa36b77af6
2 changed files with 16 additions and 18 deletions

View File

@ -4,7 +4,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include "Util.hpp" #include "Util.hpp"
namespace kabufuda namespace kabufuda

View File

@ -393,12 +393,11 @@ uint16_t BlockAllocationTable::allocateBlocks(uint16_t count, uint16_t maxBlocks
uint16_t tmpCount = count; uint16_t tmpCount = count;
while ((count--) > 0) while ((count--) > 0)
{ {
if (count == 0)
m_map[(freeBlock - FSTBlocks)] = 0xFFFF; m_map[(freeBlock - FSTBlocks)] = 0xFFFF;
else if (count != 0)
{ {
m_map[(freeBlock - FSTBlocks)] = freeBlock + 1; m_map[(freeBlock - FSTBlocks)] = nextFreeBlock(maxBlocks - FSTBlocks, m_lastAllocated + 1);
freeBlock = nextFreeBlock(maxBlocks - FSTBlocks, m_lastAllocated + 1); freeBlock = m_map[(freeBlock - FSTBlocks)];
} }
m_lastAllocated = freeBlock; m_lastAllocated = freeBlock;
} }