microtronx 38 Posted November 24, 2023 (edited) Hi All, If we have a XML element in an XML-file with more than 32k size, we got a RangeError in delphi. I tried to write a issuereport on https://github.com/kattunga/NativeXml/issues/9 but it seems that this page is not active. has someone a better solution than following lines: function TsdBufferWriter.Write(const Buffer; Count: Integer): Longint; var Idx, Siz: integer; begin // index in the source buffer Idx := 0; // remaining size Siz := Count; while FRawPosition + Siz >= FChunkSize do begin Move(TByteArray(Buffer)[Idx], FRawBuffer[FRawPosition], FChunkSize - FRawPosition); WriteChunk(FChunkSize); dec(Siz, FChunkSize - FRawPosition); inc(Idx, FChunkSize - FRawPosition); FRawPosition := 0; end; // copy the raw buffer Move(TByteArray(Buffer)[Idx], FRawBuffer[FRawPosition], Siz); inc(FRawPosition, Siz); Result := Count; end; It seems that this works only for a speficic datasize. Any ideas / hints to make it better? Edited November 24, 2023 by microtronx Share this post Link to post
microtronx 38 Posted November 24, 2023 It seems one of the declared variables as :integer was the problem. Changing all "integer" vars to "longint" and the problem is gone somehow Share this post Link to post
Sherlock 663 Posted November 24, 2023 Try NativeInt for 32Bit and 64Bit compatibility... Share this post Link to post