1.1 --- a/src/VersionDictionary.cpp Mon Sep 28 23:39:08 2009 -0700
1.2 +++ b/src/VersionDictionary.cpp Tue Sep 29 15:46:42 2009 -0700
1.3 @@ -12,13 +12,12 @@
1.4 #include "Index.h"
1.5 #include "File.h"
1.6 #include "Chunk.h"
1.7 +#include <algorithm>
1.8 #include <assert.h>
1.9 #include <errno.h>
1.10 -#include <algorithm>
1.11 +#include <stdint.h>
1.12 #include <time.h>
1.13
1.14 -# define UINT32_MAX (4294967295U)
1.15 -
1.16
1.17 namespace Mooseyard {
1.18
1.19 @@ -153,9 +152,8 @@
1.20
1.21 // Verify Indexes:
1.22 for (int i=0; i<256; i++) {
1.23 - if (_indexPositions[i] > 0)
1.24 - if (_indexPositions[i] < _previousTrailerPosition || _indexPositions[i] >= _trailerPosition)
1.25 - throw File::Error("Bad VersionDictionary trailer (illegal index position)");
1.26 + if (_indexPositions[i] >= _trailerPosition)
1.27 + throw File::Error("Bad VersionDictionary trailer (illegal index position)");
1.28 const Index *index = _index(i);
1.29 if (index)
1.30 index->validate();
1.31 @@ -289,10 +287,13 @@
1.32 dstFile->flushDisk();
1.33
1.34 // Write the trailer:
1.35 + FilePosition previousTrailerPosition = 0;
1.36 + if (dstFile==srcFile)
1.37 + previousTrailerPosition = baseDict->_trailerPosition;
1.38 FilePosition newTrailerPosition = pos;
1.39 VersionDictionary::Trailer trailer(newCount,
1.40 newIndexPositions,
1.41 - baseDict->_trailerPosition,
1.42 + previousTrailerPosition,
1.43 baseDict->generation() + 1);
1.44 pos += dstFile->write(trailer);
1.45
1.46 @@ -312,10 +313,7 @@
1.47 }
1.48 }
1.49
1.50 -
1.51 -#pragma mark -
1.52 -#pragma mark TESTING-ONLY:
1.53 -
1.54 +
1.55 VersionDictionary* VersionDictionary::_appendAndOpen (const Dictionary *addDict,
1.56 File *dstFile,
1.57 bool replace) const
1.58 @@ -326,6 +324,10 @@
1.59 return nextVersion;
1.60 }
1.61
1.62 +
1.63 +#pragma mark -
1.64 +#pragma mark TESTING-ONLY:
1.65 +
1.66 VersionDictionary* VersionDictionary::create (File *file, const Dictionary *srcDict) {
1.67 return VersionDictionary(file)._appendAndOpen(srcDict, file, true);
1.68 }