Procházet zdrojové kódy

Merged revisions 1668,1675-1676,1678 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r1668 | florian | 2005-11-06 00:02:50 +0100 (So, 06 Nov 2005) | 2 lines

* DynArrayFromVariant partly fixed

........
r1675 | florian | 2005-11-06 10:18:35 +0100 (So, 06 Nov 2005) | 2 lines

* compile with $R-

........
r1676 | florian | 2005-11-06 10:21:52 +0100 (So, 06 Nov 2005) | 2 lines

* more rangecheck fixing

........
r1678 | florian | 2005-11-06 18:16:55 +0100 (So, 06 Nov 2005) | 2 lines

* fixed DynArraySetLength

........

git-svn-id: branches/fixes_2_0@1679 -

florian před 20 roky
rodič
revize
2672e91fac
2 změnil soubory, kde provedl 18 přidání a 4 odebrání
  1. 13 1
      rtl/inc/dynarr.inc
  2. 5 3
      rtl/objpas/varutils.inc

+ 13 - 1
rtl/inc/dynarr.inc

@@ -339,7 +339,19 @@ function fpc_dynarray_copy(psrc : pointer;ti : pointer;
 
 
 procedure DynArraySetLength(var a: Pointer; typeInfo: Pointer; dimCnt: SizeInt; lengthVec: PSizeInt);
+  var
+    preallocated : array[0..10] of PSizeInt;
+    i : SizeInt;
+    p : PSizeInt;
   begin
-    int_dynarray_setlength(a,typeInfo,dimCnt,lengthVec);
+    if dimCnt<=length(preallocated) then
+      p:=@preallocated
+    else
+      getmem(p,sizeof(SizeInt)*dimCnt);
+    for i:=0 to dimCnt-1 do
+      p[i]:=lengthVec[dimCnt-1-i];
+    int_dynarray_setlength(a,typeInfo,dimCnt,p);
+    if p<>@preallocated then
+      freemem(p);
   end;
 

+ 5 - 3
rtl/objpas/varutils.inc

@@ -17,7 +17,8 @@
     Some general stuff: Error handling and so on.
   ---------------------------------------------------------------------}
 
-
+{ we so ugly things with tvararray here }
+{$RANGECHECKS OFF}
 
 Procedure SetUnlockResult (P : PVarArray; Res : HResult);
 
@@ -200,6 +201,7 @@ begin
     finally
       VariantClear(Tmp);
     end;
+  {$RANGECHECKS OFF}
 end;
 
 { ---------------------------------------------------------------------
@@ -373,7 +375,7 @@ Function SafeArrayCreate(VarType, Dim: SizeInt; const Bounds: TVarArrayBoundArra
       Result:=nil;
       end;
   end;
-  
+
 
 Function SafeArrayAllocDescriptor(DimCount: SizeInt; var psa: PVarArray): HRESULT;stdcall;
 begin
@@ -391,7 +393,7 @@ Function SafeArrayAllocData(psa: PVarArray): HRESULT;stdcall;
 begin
   try
     With psa^ do
-      begin 
+      begin
         Data:=GetMem(SafeArrayElementTotal(psa)*ElementSize);
         fillchar(Data^,SafeArrayElementTotal(psa)*ElementSize,0);
       end;