On Fri, Apr 30, 2010 at 2:48 PM, Robert Story <rst...@freesnmp.com> wrote:
> On Thu, 29 Apr 2010 08:20:35 +0200 Magnus wrote: > MF> > NEWS: snmplib: add remove function to container iterator; implement > it for > MF> > binary_array > MF> > MF> You choose to let iterator::remove move to the previous entry. I assume > MF> this means you are ruling out the possibility of a single-linked list? > > Well, I'm open for debate on the issue. My goal is to be able to remove an > item while iterating and keep the simple case simple. Using pseudocode: > > entry = itr_first; > for( ; entry; ++itr) { > // ... > if (condition) { > itr_remove; > continue; > } > // ... > } > If "++itr" accesses the memory itr points at, the above pseudocode will trigger an access to already freed memory (freed by itr_remove). > I suppose another option is for remove to set a flag, and have ++itr not > actually advance if an item was removed... That should work for singly > linked > lists to... Thoughts? > Is the above approach in your opinion really simpler than what I proposed ? Bart.
------------------------------------------------------------------------------
_______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders