From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,83f4a82a69bb9c76,start X-Google-Attributes: gid103376,public From: Graeme Perkes Subject: Creation of storage pools Date: 1999/05/26 Message-ID: <374B411C.5EA8@sydney.gecm.com>#1/1 X-Deja-AN: 482138496 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@tobruk.sydney.gecm.com X-Trace: tobruk.sydney.gecm.com 927678651 17838 203.2.118.40 (26 May 1999 00:30:50 GMT) Organization: GEC Marconi Systems Pty Limited Mime-Version: 1.0 NNTP-Posting-Date: 26 May 1999 00:30:50 GMT Newsgroups: comp.lang.ada Date: 1999-05-26T00:30:50+00:00 List-Id: There is a snippet on Ada95 storage management at the Ada source code treasury: http://www.adapower.com/lang/mempool.html I've found this example to be particularly useful for explaining how to create pre-sized storage pools. I'm trying to extend this concept by creating a package that allows a set of named storage pools to be created. Applications will then identify desired storage pools by name (i.e. a string). This is my user-defined pool type: type USER_POOL( SIZE : SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT; NAME : POOL_NAME_PTR) is new SYSTEM.STORAGE_POOLS.ROOT_STORAGE_POOL with private; procedure ALLOCATE ( POOL : in out USER_POOL; STORAGE_ADDRESS : out SYSTEM.ADDRESS; SIZE_IN_STORAGE_ELEMENTS : in SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT; ALIGNMENT : in SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT ); procedure DEALLOCATE ( POOL : in out USER_POOL; STORAGE_ADDRESS : in SYSTEM.ADDRESS; SIZE_IN_STORAGE_ELEMENTS : in SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT; ALIGNMENT : in SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT ); function STORAGE_SIZE ( POOL : in USER_POOL ) return SYSTEM.STORAGE_ELEMENTS.STORAGE_COUNT; function GET_POOL_NAME ( POOL : in USER_POOL ) return POOL_NAME; I defined an access type for this type: type POOL_PTR is access all USER_POOL; I defined an unconstrained array of POOL_PTRs: type POOL_LIST is array ( INTEGER range <> ) of POOL_PTR; I defined a pointer to this type to allow it to be easily passed to subprograms: type POOL_CFG_PTR is access all POOL_LIST; Another package is initialised with a pools list: -- STORAGE_POOLS_LIST is populated by an initialisation procedure: MY_POOL : POOL_LIST.POOL_PTR := STORAGE_POOLS_LIST(I); type INT_ACC is access INTEGER; for INT_ACC'storage_pool use MY_POOL.all; My test program is able to create a number of storage pools and call operations such as GET_POOL_NAME, STORAGE_SIZE against dereferenced elements of STORAGE_POOLS_LIST. These tests have the desired affect. The problem is how to use the storage pools I've created. I'm having trouble with "for XYZ'storage_pool use ..." syntax when used with a USER_POOL access variable: STORAGE_POOLS_LIST : POOL_CFG_PTR := null; -- STORAGE_POOLS_LIST is populated by an initialisation procedure MY_POOL : POOL_LIST.POOL_PTR := STORAGE_POOLS_LIST(I); type INT_ACC is access INTEGER; for INT_ACC'storage_pool use MY_POOL.all; GNAT 3.11b2 responds with the following error for the use clause: "incorrect reference to a Storage Pool" What am I doing wrong? What obscure syntax do I need? Am I trying to violate basic principles of storage pools? Cheers, -- Graeme Perkes GEC Marconi Systems Pty Limited mailto:graeme.perkes@gecms.com.au 40-52 Talavera Road, North Ryde Tel: +61 2 9855 8961 NSW 2113 Australia Fax: +61 2 9855 8884