comp.lang.ada
 help / color / mirror / Atom feed
* Mac memory allocation: NewPtr or Ada's "new"
@ 1997-03-16  0:00 William  C Brennan
  1997-03-16  0:00 ` Robert Dewar
  1997-03-17  0:00 ` jim hopper
  0 siblings, 2 replies; 3+ messages in thread
From: William  C Brennan @ 1997-03-16  0:00 UTC (permalink / raw)



I'm learning to do Mac programming using GNAT under CodeBuilder, 
and I'm a little confused about allocating memory from the heap.
Perhaps someone can help...

I have two Mac programming texts, and both of them tell me that
when I want to allocate memory from the heap, I should call the
NewPtr function, which seems to be functionally equivalent to the
Ada "new" allocator.  I'd prefer to use the "new" allocator because
it's not tied to an OS, but I would like to understand any
subtle differences which aren't apparent on the surface.

Is there a operational difference between calling the MacOS NewPtr 
and using Ada's "new" allocator?  How is "new" implemented for
GNAT under MacOS?  

Thanks!

--bill




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mac memory allocation: NewPtr or Ada's "new"
  1997-03-16  0:00 Mac memory allocation: NewPtr or Ada's "new" William  C Brennan
@ 1997-03-16  0:00 ` Robert Dewar
  1997-03-17  0:00 ` jim hopper
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1997-03-16  0:00 UTC (permalink / raw)



<<Is there a operational difference between calling the MacOS NewPtr
and using Ada's "new" allocator?  How is "new" implemented for
GNAT under MacOS?>>

You should be using new, unless there is some definite reason for
calling the underlying (non-portable) NewPtr function. NewPtr is
a Mac dependent function, new is the only proper portable way
to do allocation in Ada.
\x1adp





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Mac memory allocation: NewPtr or Ada's "new"
  1997-03-16  0:00 Mac memory allocation: NewPtr or Ada's "new" William  C Brennan
  1997-03-16  0:00 ` Robert Dewar
@ 1997-03-17  0:00 ` jim hopper
  1 sibling, 0 replies; 3+ messages in thread
From: jim hopper @ 1997-03-17  0:00 UTC (permalink / raw)



Bill,

gnat calls malloc for new, which is supplied by the mac standard c lib
when doing standalone apps.  calling new should be functionally
equivalant to new_ptr.   If i were you i would check out how the mac
texts suggest c programmers do it (ie malloc vs new_ptr) and do the
same as the issues are identical.  try asking it that way in
comp.sys.mac.programmer.  

sorry i don't do c on the mac unless i get paid double ;-)

new_handle on the other hand is a whole nother ball park!  Always use
new_handle rather than creating pointer to pointer so the mac os can
handle memory correctly for you.

jim

--------

In article <brennanw-1603971254020001@indian-6.vf.pond.com>
brennanw@pond.com (William  C Brennan) writes:

> I'm learning to do Mac programming using GNAT under CodeBuilder, 
> and I'm a little confused about allocating memory from the heap.
> Perhaps someone can help...
> 
> I have two Mac programming texts, and both of them tell me that
> when I want to allocate memory from the heap, I should call the
> NewPtr function, which seems to be functionally equivalent to the
> Ada "new" allocator.  I'd prefer to use the "new" allocator because
> it's not tied to an OS, but I would like to understand any
> subtle differences which aren't apparent on the surface.
> 
> Is there a operational difference between calling the MacOS NewPtr 
> and using Ada's "new" allocator?  How is "new" implemented for
> GNAT under MacOS?  




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-03-17  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-16  0:00 Mac memory allocation: NewPtr or Ada's "new" William  C Brennan
1997-03-16  0:00 ` Robert Dewar
1997-03-17  0:00 ` jim hopper

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