diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ChangeLog | 8 | ||||
| -rw-r--r-- | lib/hash.c | 11 | ||||
| -rw-r--r-- | lib/linklist.h | 1 | 
3 files changed, 18 insertions, 2 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index ea965eae..c72fa28a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2004-08-31  David Wiggins  <dwiggins@bbn.com> + +	* hash.c (hash_iterate): Save next pointer before calling +	procedure, so that iteration works even if the called procedure +	deletes the hash backet. + +	* linklist.h (listtail): new macro, not yet used. +  2004-08-27 Hasso Tepper <hasso at quagga.net>  	* command.c: Install "terminal length" commands only if vty is used. @@ -142,10 +142,17 @@ hash_iterate (struct hash *hash,  {    int i;    struct hash_backet *hb; +  struct hash_backet *hbnext;    for (i = 0; i < hash->size; i++) -    for (hb = hash->index[i]; hb; hb = hb->next) -      (*func) (hb, arg); +    for (hb = hash->index[i]; hb; hb = hbnext) +      { +	/* get pointer to next hash backet here, in case (*func) +	 * decides to delete hb by calling hash_release +	 */ +	hbnext = hb->next; +	(*func) (hb, arg); +      }  }  /* Clean up hash.  */ diff --git a/lib/linklist.h b/lib/linklist.h index 331135fe..303b0bce 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -48,6 +48,7 @@ struct list  #define nextnode(X) ((X) = (X)->next)  #define listhead(X) ((X)->head) +#define listtail(X) ((X)->tail)  #define listcount(X) ((X)->count)  #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)  #define getdata(X) ((X)->data)  | 
