Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ukma!hsdndev!bunny!mlh1 From: mlh1@gte.com (Michael Hackney) Newsgroups: comp.sys.mac.programmer Subject: Re: newD() function for ThinkC Message-ID: <11424@bunny.GTE.COM> Date: 27 Jun 91 13:47:29 GMT References: <5149@lib.tmc.edu> Distribution: usa Organization: GTE Laboratories, Waltham MA Lines: 25 In article <5149@lib.tmc.edu> jsorenso@thesis1.med.uth.tmc.edu (JEFFREY MARIUS SORENSON) writes: > I'm working on a project which involves lots of small > "direct" (implemented as pointers) objects in ThinkC. > As it stands, each time I create one of these objects > I have to go through the sequence: > > size=sizeof(ClassName); > newObject=(ClassName*)NewPtr(size); > blessD(newObject, ClassName); > Why not create a new "root" superclass (call it, say, CDObject) that looks and works exactly like CObject except it is declared as "direct"? This greatly simplifies your problem and you can mix direct and indirect classes in your application. You could also modify CObject, in which case all of the TCL would inherit "direct". This is NOT RECOMMENDED. One other point: I do not know what your need for direct classes is, but you could also just use indirect classes and call "HLock(myClass);" to lock them in memory. You can then safely pass pointers to any of the class' instance variables, etc and when you are done "HUnLock(myClass);" will ease memory management! Good luck.