Browse Source

* eoutofmemory and einvalidpointer fix

peter 24 years ago
parent
commit
47a24b5da6

+ 5 - 3
rtl/beos/sysutils.pp

@@ -254,12 +254,14 @@ Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   InitInternational;    { Initialize internationalization settings }
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-06-02 19:26:03  peter
+  Revision 1.2  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.1  2001/06/02 19:26:03  peter
     * BeOS target!
     * BeOS target!
 
 
 }
 }

+ 5 - 3
rtl/go32v2/sysutils.pp

@@ -645,12 +645,14 @@ Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   InitInternational;    { Initialize internationalization settings }
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2001-02-20 22:14:19  peter
+  Revision 1.5  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.4  2001/02/20 22:14:19  peter
     * merged getenvironmentvariable
     * merged getenvironmentvariable
 
 
   Revision 1.3  2000/08/30 06:29:19  michael
   Revision 1.3  2000/08/30 06:29:19  michael

+ 6 - 4
rtl/netware/sysutils.pp

@@ -34,7 +34,7 @@ TYPE
     EntryP: PNWDirEnt;               { and readdir }
     EntryP: PNWDirEnt;               { and readdir }
     Magic : WORD;                    { to avoid abends with uninitialized TSearchRec }
     Magic : WORD;                    { to avoid abends with uninitialized TSearchRec }
   END;
   END;
-  
+
 
 
 
 
 { Include platform independent interface part }
 { Include platform independent interface part }
@@ -475,13 +475,15 @@ Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   InitInternational;    { Initialize internationalization settings }
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
 end.
 end.
 {
 {
 
 
   $Log$
   $Log$
-  Revision 1.3  2001-04-16 18:39:50  florian
+  Revision 1.4  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.3  2001/04/16 18:39:50  florian
     * updates from Armin commited
     * updates from Armin commited
 
 
   Revision 1.2  2001/04/11 14:17:00  florian
   Revision 1.2  2001/04/11 14:17:00  florian

+ 13 - 5
rtl/objpas/sysutilh.inc

@@ -87,12 +87,17 @@ type
      public
      public
      ErrorCode : Longint;
      ErrorCode : Longint;
      end;
      end;
-   EInvalidPointer  = Class(Exception);
-   EOutOfMemory     = Class(Exception);
+   EHeapMemoryError = class(Exception)
+     protected
+     AllowFree : boolean;
+     procedure FreeInstance;override;
+     end;
+
+   EInvalidPointer  = Class(EHeapMemoryError);
+   EOutOfMemory     = Class(EHeapMemoryError);
    EAccessViolation = Class(Exception);
    EAccessViolation = Class(Exception);
    EInvalidCast = Class(Exception);
    EInvalidCast = Class(Exception);
 
 
-
    { String conversion errors }
    { String conversion errors }
    EConvertError = class(Exception);
    EConvertError = class(Exception);
 
 
@@ -136,13 +141,16 @@ Type
   {$i filutilh.inc}
   {$i filutilh.inc}
 
 
   { Read disk function declarations }
   { Read disk function declarations }
-  
+
 
 
   {$i diskh.inc}
   {$i diskh.inc}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-02-20 22:14:19  peter
+  Revision 1.9  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.8  2001/02/20 22:14:19  peter
     * merged getenvironmentvariable
     * merged getenvironmentvariable
 
 
   Revision 1.7  2001/01/18 22:09:09  michael
   Revision 1.7  2001/01/18 22:09:09  michael

+ 22 - 1
rtl/objpas/sysutils.inc

@@ -108,6 +108,12 @@
     end;
     end;
 
 
 
 
+    procedure EHeapMemoryError.FreeInstance;
+    begin
+       if AllowFree then
+        inherited FreeInstance;
+    end;
+
 
 
 {$ifopt S+}
 {$ifopt S+}
 {$define STACKCHECK_WAS_ON}
 {$define STACKCHECK_WAS_ON}
@@ -210,12 +216,24 @@ begin
   ExceptProc:=@CatchUnhandledException;
   ExceptProc:=@CatchUnhandledException;
   // Create objects that may have problems when there is no memory.
   // Create objects that may have problems when there is no memory.
   OutOfMemory:=EOutOfMemory.Create(SOutOfMemory);
   OutOfMemory:=EOutOfMemory.Create(SOutOfMemory);
+  OutOfMemory.AllowFree:=false;
   InvalidPointer:=EInvalidPointer.Create(SInvalidPointer);
   InvalidPointer:=EInvalidPointer.Create(SInvalidPointer);
+  InvalidPointer.AllowFree:=false;
   AssertErrorProc:=@AssertErrorHandler;
   AssertErrorProc:=@AssertErrorHandler;
   ErrorProc:=@RunErrorToExcept;
   ErrorProc:=@RunErrorToExcept;
   OnShowException:=Nil;
   OnShowException:=Nil;
 end;
 end;
 
 
+
+Procedure DoneExceptions;
+begin
+  OutOfMemory.AllowFree:=true;
+  OutOfMemory.Free;
+  InValidPointer.AllowFree:=true;
+  InValidPointer.Free;
+end;
+
+
 { Exception handling routines }
 { Exception handling routines }
 
 
 function ExceptObject: TObject;
 function ExceptObject: TObject;
@@ -290,7 +308,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-11-23 11:04:26  sg
+  Revision 1.4  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.3  2000/11/23 11:04:26  sg
   * Protected some Move()'s by 'if' clauses so that the Move won't be
   * Protected some Move()'s by 'if' clauses so that the Move won't be
     executed when the length would be 0. Otherwise, the corresponding
     executed when the length would be 0. Otherwise, the corresponding
     routines might get an RTE when compiled with $R+.
     routines might get an RTE when compiled with $R+.

+ 5 - 3
rtl/os2/sysutils.pp

@@ -769,13 +769,15 @@ Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   InitInternational;    { Initialize internationalization settings }
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
 end.
 end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2001-05-21 20:50:19  hajny
+  Revision 1.12  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.11  2001/05/21 20:50:19  hajny
     * silly mistyping corrected
     * silly mistyping corrected
 
 
   Revision 1.10  2001/05/20 18:40:33  hajny
   Revision 1.10  2001/05/20 18:40:33  hajny

+ 5 - 3
rtl/unix/sysutils.pp

@@ -460,13 +460,15 @@ Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   InitInternational;    { Initialize internationalization settings }
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
 end.
 end.
 {
 {
 
 
   $Log$
   $Log$
-  Revision 1.8  2001-02-20 22:19:38  peter
+  Revision 1.9  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.8  2001/02/20 22:19:38  peter
     * always test before commiting after merging, linux -> unix change
     * always test before commiting after merging, linux -> unix change
 
 
   Revision 1.7  2001/02/20 22:14:19  peter
   Revision 1.7  2001/02/20 22:14:19  peter

+ 5 - 3
rtl/win32/sysutils.pp

@@ -673,14 +673,16 @@ Initialization
     end;
     end;
 
 
 Finalization
 Finalization
-  OutOfMemory.Free;
-  InValidPointer.Free;
+  DoneExceptions;
   if kernel32dll<>0 then
   if kernel32dll<>0 then
    FreeLibrary(kernel32dll);
    FreeLibrary(kernel32dll);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-05-20 12:08:36  peter
+  Revision 1.9  2001-06-03 15:18:01  peter
+    * eoutofmemory and einvalidpointer fix
+
+  Revision 1.8  2001/05/20 12:08:36  peter
     * fixed filesearch
     * fixed filesearch
 
 
   Revision 1.7  2001/04/16 10:57:05  peter
   Revision 1.7  2001/04/16 10:57:05  peter