home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / extensible.adb < prev    next >
Encoding:
Text File  |  1995-11-17  |  2.2 KB  |  62 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/extensible.adb,v $ 
  2. -- $Revision: 1.3 $ $Date: 95/02/02 15:49:54 $ $Author: mg $ 
  3. -------------------------------------------------------------------------------
  4. --
  5. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "AS IS" WITHOUT 
  6. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
  7. -- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR 
  8. -- PURPOSE.  The user assumes the entire risk as to the accuracy and the 
  9. -- use of this file.
  10. --
  11. -- Copyright (c) Intermetrics, Inc. 1995
  12. -- Royalty-free, unlimited, worldwide, non-exclusive use, modification, 
  13. -- reproduction and further distribution of this file is permitted.
  14. --
  15. -------------------------------------------------------------------------------
  16.  
  17.  
  18. with Ada.Unchecked_Conversion;
  19. with System;
  20. with System.Storage_Elements;
  21.  
  22. package body Extensible is
  23.  
  24.     type Extended_Rec is new Integer;
  25.  
  26.     function Allocate (Actual_Elems: Big_Range) return Extended_Ptr is
  27.         function Malloc(Nbytes: Interfaces.C.Unsigned) return Extended_Ptr;
  28.         pragma Import(C, Malloc, "malloc");
  29.         use Interfaces.C;
  30.     begin
  31.         return Malloc(
  32.             Interfaces.C.Unsigned(Position_Of_Extensible_Array) + 
  33.             (((Actual_Elems-1) * Extensible_Elem'Size) / System.Storage_Unit));
  34.     end Allocate;
  35.  
  36.     procedure Free (Ptr: in out Extended_Ptr) is
  37.         procedure Do_Free(Ptr: Extended_Ptr);
  38.         pragma Import(C, Do_Free, "free");
  39.     begin
  40.         Do_Free(Ptr);
  41.         Ptr := null;
  42.     end Free;
  43.  
  44.     function Fixed_Part (Ptr: Extended_Ptr) return Fixed_Ptr is
  45.         function To_Fixed is new Ada.Unchecked_Conversion (
  46.             Extended_Ptr, Fixed_Ptr);
  47.     begin
  48.         return To_Fixed(Ptr);
  49.     end Fixed_Part;
  50.  
  51.     function Array_Part (Ptr: Extended_Ptr) return Big_Array_Ptr is
  52.         function To_Array is new Ada.Unchecked_Conversion (
  53.             System.Address, Big_Array_Ptr);
  54.         use System.Storage_Elements;
  55.     begin
  56.         return To_Array(Ptr.all'Address + 
  57.                         Storage_Offset(Position_Of_Extensible_Array));
  58.             
  59.     end Array_Part;
  60.  
  61. end Extensible;
  62.