aboutsummaryrefslogtreecommitdiff
path: root/src/nids.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-27 21:45:03 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-27 21:45:03 +0000
commit67ec9d667ab0c3f2258f6f69308d0731e74a74d0 (patch)
treeeaaccf38aeecbb22b06b0156a40cf0dbb66c7bdc /src/nids.cpp
parent00bb8c39b97638c872ebccc6aee7f3c5fb57d7d6 (diff)
downloadlibbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.gz
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.bz2
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.tar.xz
libbu++-67ec9d667ab0c3f2258f6f69308d0731e74a74d0.zip
Nids is even better, all fixed, no problems. And you can define you're own
creator functions for the cache store...soon, you'll also be able to define you're own loader/writer functions, but the default will still work exactly like this. I also did more work on nidstool, I think I may actually have to create a tools dir that will just compile some executables for the libbu++ root, because this thing is handy. You can get info on the system, trace streams' blocks, and I'm working on an analysis function that will help you figure out how to optomize your nids files. Plus, it'll have a function soon for re-writing a nids stream, which will let you change the block size, defragment, and remove unused blocks.
Diffstat (limited to 'src/nids.cpp')
-rw-r--r--src/nids.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nids.cpp b/src/nids.cpp
index 23c11b0..26a7964 100644
--- a/src/nids.cpp
+++ b/src/nids.cpp
@@ -104,7 +104,7 @@ void Bu::Nids::initialize( int iBlockSize, int iPreAllocate )
104 104
105 Block *block = (Block *)new char[iBlockSize]; 105 Block *block = (Block *)new char[iBlockSize];
106 memset( block, 0, iBlockSize ); 106 memset( block, 0, iBlockSize );
107 block->uFirstBlock = block->uNextBlock = block->uPrevBlock = blockUnused; 107 block->uFirstBlock = block->uNextBlock /*=block->uPrevBlock*/ = blockUnused;
108 for( int j = 0; j < iPreAllocate; j++ ) 108 for( int j = 0; j < iPreAllocate; j++ )
109 { 109 {
110 sStore.write( block, iBlockSize ); 110 sStore.write( block, iBlockSize );
@@ -122,9 +122,9 @@ void Bu::Nids::updateHeader()
122} 122}
123 123
124void Bu::Nids::initBlock( uint32_t uPos, uint32_t uFirstBlock, 124void Bu::Nids::initBlock( uint32_t uPos, uint32_t uFirstBlock,
125 uint32_t uPrevBlock, bool bNew ) 125 /*uint32_t uPrevBlock,*/ bool bNew )
126{ 126{
127 Block b = { uPos, blockUnused, uPrevBlock, 0, 0, { } }; 127 Block b = { uPos, blockUnused, /*uPrevBlock, 0,*/ 0, { } };
128 if( uFirstBlock != blockUnused ) 128 if( uFirstBlock != blockUnused )
129 b.uFirstBlock = uFirstBlock; 129 b.uFirstBlock = uFirstBlock;
130 bsBlockUsed.setBit( uPos ); 130 bsBlockUsed.setBit( uPos );
@@ -142,27 +142,27 @@ void Bu::Nids::initBlock( uint32_t uPos, uint32_t uFirstBlock,
142 iUsed++; 142 iUsed++;
143} 143}
144 144
145uint32_t Bu::Nids::createBlock( uint32_t uFirstBlock, uint32_t uPrevBlock, 145uint32_t Bu::Nids::createBlock( uint32_t uFirstBlock, /*uint32_t uPrevBlock,*/
146 int /*iPreAllocate*/ ) 146 int /*iPreAllocate*/ )
147{ 147{
148 for( int j = 0; j < iBlocks; j++ ) 148 for( int j = 0; j < iBlocks; j++ )
149 { 149 {
150 if( !bsBlockUsed.getBit( j ) ) 150 if( !bsBlockUsed.getBit( j ) )
151 { 151 {
152 initBlock( j, uFirstBlock, uPrevBlock ); 152 initBlock( j, uFirstBlock/*, uPrevBlock*/ );
153 return j; 153 return j;
154 } 154 }
155 } 155 }
156 // Oh, we don't have any blocks left...allocate a new one. 156 // Oh, we don't have any blocks left...allocate a new one.
157 iBlocks++; 157 iBlocks++;
158 bsBlockUsed.setSize( iBlocks, false ); 158 bsBlockUsed.setSize( iBlocks, false );
159 initBlock( iBlocks-1, uFirstBlock, uPrevBlock, true ); 159 initBlock( iBlocks-1, uFirstBlock/*, uPrevBlock*/, true );
160 return iBlocks-1; 160 return iBlocks-1;
161} 161}
162 162
163int Bu::Nids::createStream( int iPreAllocate ) 163int Bu::Nids::createStream( int iPreAllocate )
164{ 164{
165 return createBlock( blockUnused, blockUnused, iPreAllocate ); 165 return createBlock( blockUnused, /*blockUnused,*/ iPreAllocate );
166} 166}
167 167
168void Bu::Nids::deleteStream( int /*iID*/ ) 168void Bu::Nids::deleteStream( int /*iID*/ )
@@ -224,7 +224,7 @@ void Bu::Nids::updateStreamSize( uint32_t uIndex, uint32_t uSize )
224{ 224{
225 if( !sStore.canWrite() ) 225 if( !sStore.canWrite() )
226 return; 226 return;
227 sStore.setPos( iBlockStart + (iBlockSize*uIndex)+4*3 ); 227 sStore.setPos( iBlockStart + (iBlockSize*uIndex)+4*2 );
228 sStore.write( &uSize, 4 ); 228 sStore.write( &uSize, 4 );
229} 229}
230 230