At 7:17 +0200 6/7/05, Frank Heckenbach wrote:
Peter N Lewis wrote:
I'm always hesitant to use Pascal's New in case it does weird things like many Pascals do to support Mark/Release/etc. It appears that GPC calls straight through to malloc/free, with little overhead and no messing around unless Mark/Release procedures are called.
Yes. (And quite frankly, Pascal without `New' would be quite a crippled language. For Mac Objects, besides many other things, you need `New' anyway, don't you?)
For Mac objects, there is no choice.
For all other pointers, I use the system call NewPtr, or NewHandle (a Mac Handle is a Ptr to a Ptr that the memory manage knows as a special construct allowing it to be resized while the handle remains unchanged, it was used a lot in the earlier days of much more restricted memory to allow the memory manager to defragment the heap).
For serious programming, some Pascal's horrendous memory allocation schemes render the language next to useless. Several Pascals have their own memory allocation system so that once memory is taken from the system it is never returned.
But I'm happy to hear I can use it safely with GPC and it will just call through to the system malloc/free.
CW Pascal is probably the same, but old habits (and anxieties) die hard. Peter.