pointers and pointers. 
Author Message
 pointers and pointers.

Could anyone supply me with a short and simple example of pointer use in
ADA.
From what I gather, they are called access types in ADA??

If so, a list example with a garbage collector would be great as an example.
Thanks a bunch!



Thu, 29 May 2003 07:40:33 GMT  
 pointers and pointers.


Quote:
> Could anyone supply me with a short and simple example of
pointer use in
> ADA.
> From what I gather, they are called access types in ADA??

> If so, a list example with a garbage collector would be great

as an example.

Any text book on Ada will have lots of examples of the use
of access types. That is where you should look.

Funny, that's the second person this week who wanted us to
write a garbage collector for them :-) :-)

Sent via Deja.com http://www.deja.com/
Before you buy.



Thu, 29 May 2003 10:22:13 GMT  
 pointers and pointers.

Quote:

> Any text book on Ada will have lots of examples of the use
> of access types. That is where you should look.

I think you'll find that most text books use the linked list example, but
completely fail to mention how you should deallocate the memory grabbed by
the new operator when you remove the item from the list. I've had lists that
grow to 40MB before I empty them, so I want to be sure that the memory is
being deallocated properly. Do I have to use an unchecked_deallocation to do
this or is there a neater (better) way?

Any expansion on this vague topic over and above what the text books say
would be gladly received, because quite frankly most of them give rise to
more FAQs than they answer.

I learnt what I know (which isn't a lot) by looking at the source examples
for the GNAT implementation of the unbounded_strings and generic queue.

Any explanations in Ada 83 terms rather than Ada 95 would be preferred by
me.

Nick



Mon, 02 Jun 2003 06:16:30 GMT  
 pointers and pointers.
You can always have an internal linked list of unused, available elements.
Then, deallocation consists of placing the element in the list.  Whenever you
need a new element, get it from the internal list and only allocate a new
element when the internal list is empty.

Quote:

> > Any text book on Ada will have lots of examples of the use
> > of access types. That is where you should look.

> I think you'll find that most text books use the linked list example, but
> completely fail to mention how you should deallocate the memory grabbed by
> the new operator when you remove the item from the list. I've had lists that
> grow to 40MB before I empty them, so I want to be sure that the memory is
> being deallocated properly. Do I have to use an unchecked_deallocation to do
> this or is there a neater (better) way?

> Any expansion on this vague topic over and above what the text books say
> would be gladly received, because quite frankly most of them give rise to
> more FAQs than they answer.

> I learnt what I know (which isn't a lot) by looking at the source examples
> for the GNAT implementation of the unbounded_strings and generic queue.

> Any explanations in Ada 83 terms rather than Ada 95 would be preferred by
> me.

> Nick


--
Larry Hazel


Mon, 02 Jun 2003 06:33:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ISO C Binding: Pointer to a pointer of pointers: ***argv

2. Pointers to pointers possible?

3. Pointer to pointer with LabVIEW 4.1?

4. Returning Pointer To Pointer From Function

5. Implementing pointers to pointers in Ada

6. pointer to pointer to field / dynamic field

7. pointers to pointers

8. Pointer to pointer to BSTR?

9. change "pointer to pointer" in C to something else in Fortran

10. A pointer to an array of pointers

11. A couple of simple pointer questions (targets, arrays of pointers)

12. Deallocation of a pointer which points to a type containing allocated pointers

 

 
Powered by phpBB® Forum Software