swarm-support
[Top][All Lists]
Advanced

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

Re: object removal from list causing core dump


From: Doug Donalson;
Subject: Re: object removal from list causing core dump
Date: Thu, 21 May 1998 23:54:30 -0700 (PDT)

Here is some code that I think will let you use your while loop.
Once you get the id of the list member you want to remove, try this:

  index1= [list createIndex: [self getZone] fromMember: memberId];
  [index1 remove]; // This removes the member
  [index1 drop];

You should be able to use this inside the loop.  I think?  :-)
Let me know if this works.  Also, remember to drop both indexes
and if the object removed is no longer being used, drop it too.

Cheers,

   Doug


***************************************************************************
* Doug Donalson                          * Office: (805) 893-2962         *
* Ecology, Evolution, and Marine Biology * Home:   (805) 961-4447         *
* UC Santa Barbara                       * email address@hidden
* Santa Barbara Ca. 93106                *                                *
***************************************************************************
*                                                                         *
*   The most exciting phrase to hear in science, the one that             *
*   heralds new discoveries, is not "EUREKA" (I have found it) but        *
*   "That's funny ...?"                                                   *
*                                                                         *
*       Isaac Asimov                                                      *
*                                                                         *
***************************************************************************


On Thu, 21 May 1998, Geoffrey Schultz wrote:

> Hi,
> 
> I'm having a bit of problem with my simulation and was wondering
> whether I'm committing a no-no.
> 
> I have a list that will contain a variable but small number of
> objects.  If I set up the following code bit, I get a seg fault and core
> dump.  Is their something wrong with this:
> 
> index=[MyList begin: scratchZone];
> while((anObject=[index next])){
> 
> // check certain properties of the object and
> // if meets criteria:
> 
>   if(condition)
>       [MyList remove: anObject];
> 
> }
> 
> does removing a member while in a "while" statement cause a problem with
> indexing? The list initailly has only the single member (that is removed)
> but at other times in the simulation may contain more than one member.
> 
> I can supply the complete backtrace, however the last line 
> 
> says
> 
> -[ListIndex() at List_GEN.m: 295
> 
> (using ddd as debugger)
> 
> 
> Thanks,
> 
> Geoff Schultz
> 
> 
>                   ==================================
>    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.
>                   ==================================
> 

                  ==================================
   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]