comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: A simple question about the "new" allocator
Date: Wed, 13 Aug 2014 09:36:43 +0200
Date: 2014-08-13T09:36:43+02:00	[thread overview]
Message-ID: <2g7jja99fq2x$.5crvfujapxfi$.dlg@40tude.net> (raw)
In-Reply-To: 15e09ab5-804e-4070-9ad2-46dc18d17505@googlegroups.com

On Tue, 12 Aug 2014 16:41:10 -0700 (PDT), Adam Beneschan wrote:

> Not necessarily.  Nothing says Pool has to have the memory used for
> allocation as part of the object.  The Initialize routine could allocate a
> byte array on the normal heap.  If this byte array isn't deallocated by
> My_Storage_Pool's Finalize routine, then the storage won't be reclaimed.
> 
> This isn't really relevant to the real world, since hopefully nobody would
> write My_Storage_Pool like that.

Why? "Proxy pools" are quite useful.

Consider an implementation of doubly-linked list. The pointer to an element
goes to the proxy pool. Upon allocation the pool gets memory from the heap.
It allocates more memory than needed to keep the element adding space for
the list's forward and backward links. The advantage of this approach is
that the element can be of any type used as-is, links are totally
invisible, no extra redirection needed, pointer to the element is plain
direct access type.

Simple components has such an implementation:

http://www.dmitry-kazakov.de/ada/components.htm#Generic_Doubly_Linked_Web

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2014-08-13  7:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  6:54 A simple question about the "new" allocator NiGHTS
2014-08-12  7:35 ` Dmitry A. Kazakov
2014-08-12 13:38   ` G.B.
2014-08-12 10:29 ` sbelmont700
2014-08-12 18:49   ` Shark8
2014-08-12 19:10     ` Adam Beneschan
2014-08-12 21:53       ` Niklas Holsti
2014-08-12 22:34         ` Adam Beneschan
2014-08-12 23:14           ` sbelmont700
2014-08-12 23:41             ` Adam Beneschan
2014-08-13  7:36               ` Dmitry A. Kazakov [this message]
2014-08-13 15:04                 ` Adam Beneschan
2014-08-13 20:32           ` Niklas Holsti
2014-08-12 15:10 ` Adam Beneschan
2014-08-12 16:07 ` Jeffrey Carter
2014-08-12 19:58   ` Robert A Duff
2014-08-12 17:51 ` NiGHTS
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox