mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
Fixed bug where generating a search for a chm with millions of words would use 4GB of memory!
git-svn-id: trunk@20479 -
This commit is contained in:
parent
a7b46fc36f
commit
4788c38f2c
@ -287,7 +287,7 @@ begin
|
|||||||
// write the glorious header
|
// write the glorious header
|
||||||
FHeaderRec.Sig[2] := $28;
|
FHeaderRec.Sig[2] := $28;
|
||||||
FHeaderRec.HTMLFilesCount := FWordList.IndexedFileCount;
|
FHeaderRec.HTMLFilesCount := FWordList.IndexedFileCount;
|
||||||
FHeaderRec.RootNodeOffset := FStream.Size-4096;
|
FHeaderRec.RootNodeOffset := FStream.Size-FIFTI_NODE_SIZE;
|
||||||
FHeaderRec.LeafNodeCount := TLeafNode(FActiveLeafNode).LeafNodeCount;
|
FHeaderRec.LeafNodeCount := TLeafNode(FActiveLeafNode).LeafNodeCount;
|
||||||
FHeaderRec.CopyOfRootNodeOffset := FHeaderRec.RootNodeOffset;
|
FHeaderRec.CopyOfRootNodeOffset := FHeaderRec.RootNodeOffset;
|
||||||
FHeaderRec.TreeDepth := 0;
|
FHeaderRec.TreeDepth := 0;
|
||||||
@ -305,7 +305,7 @@ begin
|
|||||||
//FHeaderRec.CodeCountRootSize := 15;
|
//FHeaderRec.CodeCountRootSize := 15;
|
||||||
//FHeaderRec.LocationCodeRootSize := 15;
|
//FHeaderRec.LocationCodeRootSize := 15;
|
||||||
|
|
||||||
FHeaderRec.NodeSize := 4096;
|
FHeaderRec.NodeSize := FIFTI_NODE_SIZE;
|
||||||
FHeaderRec.LongestWordLength := FWordList.LongestWord;
|
FHeaderRec.LongestWordLength := FWordList.LongestWord;
|
||||||
FHeaderRec.TotalWordsIndexed := FWordList.TotalWordCount;
|
FHeaderRec.TotalWordsIndexed := FWordList.TotalWordCount;
|
||||||
FHeaderRec.TotalWords := FWordList.TotalDIfferentWords;
|
FHeaderRec.TotalWords := FWordList.TotalDIfferentWords;
|
||||||
@ -549,6 +549,8 @@ begin
|
|||||||
WLCSize := WriteWLCEntries(AWord, FDocRootSize, FCodeRootSize, FLocRootSize);
|
WLCSize := WriteWLCEntries(AWord, FDocRootSize, FCodeRootSize, FLocRootSize);
|
||||||
|
|
||||||
WriteCompressedIntegerBE(FBlockStream, WLCSize);
|
WriteCompressedIntegerBE(FBlockStream, WLCSize);
|
||||||
|
if FBlockStream.Position > FIFTI_NODE_SIZE then
|
||||||
|
raise Exception.Create('FIFTIMAIN Leaf node has written past the block!');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Min(AValue, BValue: Byte): Byte;
|
function Min(AValue, BValue: Byte): Byte;
|
||||||
@ -692,6 +694,8 @@ begin
|
|||||||
FBlockStream.Write(AWord[1], Length(AWord));
|
FBlockStream.Write(AWord[1], Length(AWord));
|
||||||
FBlockStream.WriteDWord(NtoLE(ANodeOffset));
|
FBlockStream.WriteDWord(NtoLE(ANodeOffset));
|
||||||
FBlockStream.WriteWord(0);
|
FBlockStream.WriteWord(0);
|
||||||
|
if FBlockStream.Position > FIFTI_NODE_SIZE then
|
||||||
|
raise Exception.Create('FIFTIMAIN Index node has written past the block!');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIndexNode.Flush ( NewBlockNeeded: Boolean ) ;
|
procedure TIndexNode.Flush ( NewBlockNeeded: Boolean ) ;
|
||||||
@ -718,6 +722,7 @@ begin
|
|||||||
FBlockStream.Position := 0;
|
FBlockStream.Position := 0;
|
||||||
|
|
||||||
FWriteStream.CopyFrom(FBlockStream, FIFTI_NODE_SIZE);
|
FWriteStream.CopyFrom(FBlockStream, FIFTI_NODE_SIZE);
|
||||||
|
FBlockStream.Position := 0;
|
||||||
|
|
||||||
FLastWord := '';
|
FLastWord := '';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user