Browse Source

* Force 4-byte alignment of fields in record-buffers hwn necessary

git-svn-id: trunk@11134 -
joost 17 years ago
parent
commit
8aa27c6254
1 changed files with 8 additions and 0 deletions
  1. 8 0
      packages/fcl-db/src/base/bufdataset.pas

+ 8 - 0
packages/fcl-db/src/base/bufdataset.pas

@@ -1807,12 +1807,20 @@ var x : longint;
 
 
 begin
 begin
   FNullmaskSize := 1+((FieldDefs.count-1) div 8);
   FNullmaskSize := 1+((FieldDefs.count-1) div 8);
+{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
+  if (FNullmaskSize and 3 <> 0) then
+    FNullmaskSize := (FNullmaskSize and not 3)+4;
+{$ENDIF}
   FRecordSize := FNullmaskSize;
   FRecordSize := FNullmaskSize;
   SetLength(FFieldBufPositions,FieldDefs.count);
   SetLength(FFieldBufPositions,FieldDefs.count);
   for x := 0 to FieldDefs.count-1 do
   for x := 0 to FieldDefs.count-1 do
     begin
     begin
     FFieldBufPositions[x] := FRecordSize;
     FFieldBufPositions[x] := FRecordSize;
     inc(FRecordSize, GetFieldSize(FieldDefs[x]));
     inc(FRecordSize, GetFieldSize(FieldDefs[x]));
+{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
+  if (FRecordSize and 3 <> 0) then
+    FRecordSize := (FRecordSize and not 3)+4;
+{$ENDIF}
     end;
     end;
 end;
 end;