Xref: utzoo comp.sys.mac.programmer:4513 comp.lang.c:16285 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.sys.mac.programmer,comp.lang.c Subject: Re: Mac LightSpeed C question (elementary) Message-ID: <11781@haddock.ima.isc.com> Date: 16 Feb 89 01:40:25 GMT References: <1158@naucse.UUCP> <423@lakart.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 20 In article <423@lakart.UUCP> fgz@lakart.UUCP (Federico Genoese-Zerbi) writes: >From article <1158@naucse.UUCP>, by rrw@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@haddock.isc.com), The Walking Lint