Inline Unset and SetTo correctly. I copied the class from BFS which only uses it in a single file...

Thx for the gcc4 fixes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28166 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-10-16 10:05:59 +00:00
parent 433579eaf5
commit 861fb97cf9
2 changed files with 31 additions and 26 deletions

View File

@ -15,8 +15,8 @@
#include <util/kernel_cpp.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
using namespace FATFS;
@ -47,28 +47,3 @@ CachedBlock::~CachedBlock()
}
void
CachedBlock::Unset()
{
fBlockNumber = -1;
}
uint8 *
CachedBlock::SetTo(off_t block)
{
if (block == fBlockNumber)
return fBlock;
if (fBlock == NULL) {
fBlock = (uint8 *)malloc(BlockSize());
if (fBlock == NULL)
return NULL;
}
fBlockNumber = block;
if (read_pos(fVolume.Device(), block << BlockShift(), fBlock, BlockSize()) < (ssize_t)BlockSize())
return NULL;
return fBlock;
}

View File

@ -10,6 +10,8 @@
#include <SupportDefs.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include "Volume.h"
@ -36,6 +38,34 @@ class CachedBlock {
uint8 *fBlock;
};
inline void
CachedBlock::Unset()
{
fBlockNumber = -1;
}
inline uint8 *
CachedBlock::SetTo(off_t block)
{
if (block == fBlockNumber)
return fBlock;
if (fBlock == NULL) {
fBlock = (uint8 *)malloc(BlockSize());
if (fBlock == NULL)
return NULL;
}
fBlockNumber = block;
if (read_pos(fVolume.Device(), block << BlockShift(), fBlock, BlockSize()) < (ssize_t)BlockSize())
return NULL;
return fBlock;
}
} // namespace FATFS
#endif /* CACHED_BLOCK_H */