-- --
-- S Y S T E M . M E M O R Y --
-- --
--- S p e c --
+-- B o d y --
-- --
--- $Revision: 1.2 $
--- --
--- Copyright (C) 2001 Free Software Foundation, Inc. --
--- --
--- This specification is derived from the Ada Reference Manual for use with --
--- GNAT. The copyright notice above, and the license provisions that follow --
--- apply solely to the contents of the part following the private keyword. --
+-- Copyright (C) 2001-2003 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions;
with System.Soft_Links;
+with System.Parameters;
+with System.CRTL;
package body System.Memory is
use Ada.Exceptions;
use System.Soft_Links;
- function c_malloc (Size : size_t) return System.Address;
- pragma Import (C, c_malloc, "malloc");
+ function c_malloc (Size : System.CRTL.size_t) return System.Address
+ renames System.CRTL.malloc;
- procedure c_free (Ptr : System.Address);
- pragma Import (C, c_free, "free");
+ procedure c_free (Ptr : System.Address)
+ renames System.CRTL.free;
function c_realloc
- (Ptr : System.Address; Size : size_t) return System.Address;
- pragma Import (C, c_realloc, "realloc");
+ (Ptr : System.Address; Size : System.CRTL.size_t) return System.Address
+ renames System.CRTL.realloc;
-----------
-- Alloc --
Actual_Size := 1;
end if;
- Abort_Defer.all;
- Result := c_malloc (Actual_Size);
- Abort_Undefer.all;
+ if Parameters.No_Abort then
+ Result := c_malloc (System.CRTL.size_t (Actual_Size));
+ else
+ Abort_Defer.all;
+ Result := c_malloc (System.CRTL.size_t (Actual_Size));
+ Abort_Undefer.all;
+ end if;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");
procedure Free (Ptr : System.Address) is
begin
- Abort_Defer.all;
- c_free (Ptr);
- Abort_Undefer.all;
+ if Parameters.No_Abort then
+ c_free (Ptr);
+ else
+ Abort_Defer.all;
+ c_free (Ptr);
+ Abort_Undefer.all;
+ end if;
end Free;
-------------
return System.Address
is
Result : System.Address;
- Actual_Size : size_t := Size;
+ Actual_Size : constant size_t := Size;
begin
if Size = size_t'Last then
Raise_Exception (Storage_Error'Identity, "object too large");
end if;
- Abort_Defer.all;
- Result := c_realloc (Ptr, Actual_Size);
- Abort_Undefer.all;
+ if Parameters.No_Abort then
+ Result := c_realloc (Ptr, System.CRTL.size_t (Actual_Size));
+ else
+ Abort_Defer.all;
+ Result := c_realloc (Ptr, System.CRTL.size_t (Actual_Size));
+ Abort_Undefer.all;
+ end if;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");