Jump to content
Sign in to follow this  
microtronx

NativeXML and tsdBufferWrite problems with 32k

Recommended Posts

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 by microtronx

Share this post


Link to post

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×