What's the meaning of empty record??

What's the meaning of empty record??

in Datasnap.DBClient, there is :

TKeyBuffer = record
Modified: Boolean;
Exclusive: Boolean;
FieldCount: Integer;
Data: record end;
end;

Comments

  1. 丽丽乌克 It's declared as empty record to indicate variable length at runtime when it will be populated with some presumably non-zero-size data. (Similar to untyped var parameter). e.g. var buf: PKeyBuffer; buf := AllocMem(SizeOf(TKeyBuffer) + FRecordSize); see TCustomClientDataSet.AllocKeyBuffers

    ReplyDelete
  2. 丽丽乌克 you can't, but this is a generic type.

    Keybuffers are allocated with AllocMem(SizeOf(TKeyBuffer) + FRecordSize); and the Record data is located at @Keybuffer.Data.

    the function GetActiveRecBuf should use it to know the location of the RecBuf...but it doesn't :)

    Tokyo: RecBuf := NativeInt(PByte(FKeyBuffer) + SizeOf(TKeyBuffer));

    XE3: RecBuf := PByte(FKeyBuffer) + SizeOf(TKeyBuffer);

    it could be PByte(@FKeyBuffer.Data) or NativeInt(@FKeybuffer.Data) for Tokyo

    ReplyDelete
  3. Paul TOTH Ondrej Kelle Thanks for the explanation!

    ReplyDelete

Post a Comment