swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KeyedCollection protocol ? (fwd)


From: glen e. p. ropella
Subject: Re: KeyedCollection protocol ? (fwd)
Date: Tue, 25 Nov 1997 06:26:18 -0700

Ken Cline writes:
 > I suspect this ommission is reponsible for compiler warnings
 > such as:
 > 
 > {loon:kcline:46} make
 > gcc  -c -mv8 -O3 -Wall -Wno-import  -I./SWARMHOME/include \
 >      -I./SWARMHOME/needed-software/include \
 >      -I./SWARMHOME/needed-software/src/libtclobjc/libtclobjc-1.1b6 \
 >      -I./SWARMHOME/needed-software/src/xpm/xpm-3.4j \
 >      -I/usr/openwin/include  BdGrid2D.m
 > 
 > BdGrid2D.m: In function `_i_BdGrid2D__printObjectSet':
 > BdGrid2D.m:800: warning: method `getCount' not implemented by protocol.
 > BdGrid2D.m:804: warning: method `atOffset:' not implemented by protocol.
 > 
 > rm -f SWARMHOME/lib/libspatial.a
 > ar q SWARMHOME/lib/libspatial.a spatial.o Point2D.o \
 >      Point3D.o BdGrid2D.o Obj2DDisplay.o
 > ranlib ./SWARMHOME/lib/libspatial.a
 > 
 > {loon:kcline:47} 
 > 
 > 
 > BdGrid2D.m, Line 800:
 >    if ( objectSet == NULL || (n = [objectSet getCount]) <= 0 )
 > 
 > where objectSet is type `id <Set>'.
 > 
 > NOTE: These are just warnings, *no* error occurs at runtime.

Yep.  And you could get rid of those warnings (I think) by
not using the "<Set>" protocol match... at least until we
get the inheritance from <Collection> fixed.

 > I've since realized that I probably shouldn't use a Set
 > since several methods are not implemented and according to
 > an archive message the Set class is suppose to be completely
 > re-implemented at some time. 

Well, the idea is that the interface won't change, even if
the implementation does.

Ken Cline writes:
 > I also seems that some of the Set.m code has memory leaks,
 > for example:
 >  
 >     - at: aKey
 >     {
 >         id  index, member;
 >  
 >         index = [(id)list begin: scratchZone];
 >         while ( (member = [index next]) ) {
 >           if ( member == aKey ) return member;
 >         }
 >         [index drop];
 >         return nil;
 >     }
 >    
 > If `member == aKey' then `index' is *not* `drop'-ed,
 > correct?  (The Map.m code is different, btw.)  I was
 > wondering is the scratchZone is a special zone for only
 > locally allocated objects?  If scratchZone is just for local
 > allocation then freeing its memory isn't critical?

ScratchZone isn't regularly cleaned up, if that's what you
mean.  It is intended for temporary allocation (not necessarily
restricted in locality).  And at some point, we'd hope to put
in some code that flushed it whenever we ran into memory 
problems (or simply on a regular basis); but, we don't do that
now.

This is probably a memory leak.  It's an excellent example
of what happens when one is trying too hard to be succinct
in their coding.  The basic rule to avoid stuff like this
is "Thou shalt not have multiple exit points from a code
unit!"

 > Anyway, I'm going to use a Map instead of a Set.  I just
 > wanted to point this out.

Why?  What is the object for?

glen
-- 
{glen e. p. ropella <address@hidden> |  Send lawyers, guns, and money!  }
{Hive Drone, SFI Swarm Project         |            Hail Eris!            }
{http://www.trail.com/~gepr/home.html  |               =><=               }

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]