Explorar el Código

* fixed wrong freemem size when loading message file

peter hace 25 años
padre
commit
4216d26c2f
Se han modificado 1 ficheros con 19 adiciones y 6 borrados
  1. 19 6
      compiler/messages.pas

+ 19 - 6
compiler/messages.pas

@@ -29,6 +29,7 @@ type
   PMessage=^TMessage;
   PMessage=^TMessage;
   TMessage=object
   TMessage=object
     msgfilename : string;
     msgfilename : string;
+    msgallocsize,
     msgsize,
     msgsize,
     msgs        : longint;
     msgs        : longint;
     msgtxt      : pchar;
     msgtxt      : pchar;
@@ -55,6 +56,7 @@ uses
 constructor TMessage.Init(p:pointer;n:longint);
 constructor TMessage.Init(p:pointer;n:longint);
 begin
 begin
   msgtxt:=pchar(p);
   msgtxt:=pchar(p);
+  msgallocsize:=0;
   msgsize:=0;
   msgsize:=0;
   msgs:=n;
   msgs:=n;
   CreateIdx;
   CreateIdx;
@@ -125,7 +127,8 @@ begin
       end;
       end;
    end;
    end;
 { now read the buffer in mem }
 { now read the buffer in mem }
-  getmem(msgtxt,msgsize);
+  msgallocsize:=msgsize;
+  getmem(msgtxt,msgallocsize);
   ptxt:=msgtxt;
   ptxt:=msgtxt;
   reset(f);
   reset(f);
   while not eof(f) do
   while not eof(f) do
@@ -163,10 +166,17 @@ end;
 
 
 destructor TMessage.Done;
 destructor TMessage.Done;
 begin
 begin
-  if not (msgidx=nil) then
-   freemem(msgidx,msgs shl 2);
-  if msgsize>0 then
-   freemem(msgtxt,msgsize);
+  if assigned(msgidx) then
+   begin
+     freemem(msgidx,msgs shl 2);
+     msgidx:=nil;
+   end;
+  if msgallocsize>0 then
+   begin
+     freemem(msgtxt,msgallocsize);
+     msgtxt:=nil;
+     msgallocsize:=0;
+   end;
 end;
 end;
 
 
 
 
@@ -264,7 +274,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2000-01-07 01:14:27  peter
+  Revision 1.10  2000-01-23 16:32:08  peter
+    * fixed wrong freemem size when loading message file
+
+  Revision 1.9  2000/01/07 01:14:27  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.8  1999/07/18 10:19:55  florian
   Revision 1.8  1999/07/18 10:19:55  florian