You are not logged in.
Pages: 1
mormot.core.buffers.pas
procedure TMemoryMapText.LoadFromMap(AverageLineLength: integer = 32);
var
P: PUtf8Char;
begin
fLinesMax := fMap.FileSize div AverageLineLength + 8;
GetMem(fLines, fLinesMax * SizeOf(pointer));
P := pointer(fMap.Buffer);
fMapEnd := P + fMap.Size;
// except when loading a empty file. (P = nil)
if (PWord(P)^ = $BBEF) and
(P[2] = #$BF) then
inc(P, 3); // ignore UTF-8 BOM
ParseLines(P, fMapEnd, self);
if fLinesMax > fCount + 16384 then
Reallocmem(fLines, fCount * SizeOf(pointer)); // size down only if worth it
end;
Offline
How do you initialize TMemoryMapText ?
LoadFromMap should not be called if the file was empty.
Anyway, please try https://github.com/synopse/mORMot2/commit/6af3d452
Offline
For example:
var
mmt: TMemoryMapText;
begin
if not FileExists(fileName) then
Exit;
mmt := TMemoryMapText.Create(fileName); // exception
...
end;
Offline
Pages: 1