Re: NewPtr vs malloc
Re: NewPtr vs malloc
- Subject: Re: NewPtr vs malloc
- From: "Tomas Zahradnicky, Jr." <email@hidden>
- Date: Sat, 8 Dec 2001 21:57:21 +0100
On Thursday, December 6, 2001, at 10:12 am, Joe Chang (l%l,m8) wrote:
Hi all,
I'm wondering if there are differences between NewPtr and malloc,
DisposePtr and free. Which ones are better? or just same?
They are both the same, i would use malloc vs NewPtr, since its more
standard (exact same code will work everywhere)
Hello,
Althrough they might seem the same, they are not. ptr = NewPtr(size)
is mac os toolbox function which allocates free pointer block. You
may want to allocate ptr = NewPtrClear(size) --- a cleared pointer
block. You can get size of that block GetPtrSize(ptr) or tell user
why the allocation failed err = MemError() right after a call to
NewPtr. You may also resize the block using SetPtrSize and MemError
afterwards.
-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# FEL-CTU, Prague