Mac LightSpeed C question (elementary)
Karl Heuer
karl at haddock.ima.isc.com
Thu Feb 16 11:40:25 AEST 1989
In article <423 at lakart.UUCP> fgz at lakart.UUCP (Federico Genoese-Zerbi) writes:
>From article <1158 at naucse.UUCP>, by rrw at naucse.UUCP (Robert Wier):
>>I have gotten around this problem in Pascal programs by doing allocate and
>>dispose operations. Is there something equivalent in C?
The library routines malloc() and free() are the usual way of doing this.
>There is. However, try the following:
> ptr = (variable type *)NewPtr(size needed);
>the C allocators used in Lightspeed end up calling NewPtr anyway. To
>deallocate try:
> DisposPtr(ptr);
Is there any good reason to use these rather than the standard interface? If
the only answer is that it avoids one function-call overhead, then I suggest
that (a) portability is important, even if you have no current plans to port
this program, and (b) malloc() and free() ought to be implemented as macros on
that system.
Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
More information about the Comp.lang.c
mailing list