فهرست منبع

* fixed bug with reallocmem to use the wrong size when copying the
data to the new allocated pointer

peter 25 سال پیش
والد
کامیت
20105af42c
2فایلهای تغییر یافته به همراه16 افزوده شده و 4 حذف شده
  1. 8 2
      rtl/inc/heap.inc
  2. 8 2
      rtl/inc/heaptrc.pp

+ 8 - 2
rtl/inc/heap.inc

@@ -668,6 +668,7 @@ end;
 
 function SysReAllocMem(var p:pointer;size : longint):pointer;
 var
+  oldsize : longint;
   p2 : pointer;
 begin
   { Free block? }
@@ -686,9 +687,10 @@ begin
    { Resize block }
    if not SysTryResizeMem(p,size) then
     begin
+      oldsize:=MemoryManager.MemSize(p);
       p2:=MemoryManager.GetMem(size);
       if p2<>nil then
-       Move(p^,p2^,size);
+       Move(p^,p2^,oldsize);
       MemoryManager.FreeMem(p);
       p:=p2;
     end;
@@ -805,7 +807,11 @@ end;
 
 {
   $Log$
-  Revision 1.33  2000-02-02 11:12:29  peter
+  Revision 1.34  2000-02-10 13:59:35  peter
+    * fixed bug with reallocmem to use the wrong size when copying the
+      data to the new allocated pointer
+
+  Revision 1.33  2000/02/02 11:12:29  peter
     * fixed internal_memavail counting for tryresizemem
 
   Revision 1.32  2000/01/31 23:41:30  peter

+ 8 - 2
rtl/inc/heaptrc.pp

@@ -760,6 +760,7 @@ end;
 function TraceReAllocMem(var p:pointer;size:longint):Pointer;
 var
   newP: pointer;
+  oldsize,
   i,bp : longint;
   pl : plongint;
   pp : pheap_mem_info;
@@ -799,10 +800,11 @@ begin
      { restore p }
      inc(p,sizeof(theap_mem_info)+extra_info_size);
      { get a new block }
+     oldsize:=TraceMemSize(p);
      newP := TraceGetMem(size);
      { move the data }
      if newP <> nil then
-       move(p^,newP^,size);
+       move(p^,newP^,oldsize);
      { release p }
      traceFreeMem(p);
      p := newP;
@@ -975,7 +977,11 @@ finalization
 end.
 {
   $Log$
-  Revision 1.40  2000-02-09 16:59:30  peter
+  Revision 1.41  2000-02-10 13:59:35  peter
+    * fixed bug with reallocmem to use the wrong size when copying the
+      data to the new allocated pointer
+
+  Revision 1.40  2000/02/09 16:59:30  peter
     * truncated log
 
   Revision 1.39  2000/02/07 10:42:44  peter