diff options
author | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-12-02 16:39:05 +0000 |
---|---|---|
committer | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-12-02 16:39:05 +0000 |
commit | aa04a120d60b4001bb6224a7efd6d49fec7ec622 (patch) | |
tree | eadd9addde1707db9861d09d5a0435f76644d6da | |
parent | 6da0ef7dc8e72cba979fbc8b1fe42e75bdc5afcd (diff) | |
download | quagga-aa04a120d60b4001bb6224a7efd6d49fec7ec622.tar.bz2 quagga-aa04a120d60b4001bb6224a7efd6d49fec7ec622.tar.xz |
Avoid deleting symbol reference twice in prefix_list_delete().
Affects: lib/plist.c
Merged otherwise unused prefix_list_free() into prefix_list_delete(),
and removed second call of symbol_unset_value().
-rw-r--r-- | lib/plist.c | 87 |
1 files changed, 37 insertions, 50 deletions
diff --git a/lib/plist.c b/lib/plist.c index 9976b81c..10d5e31c 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -499,19 +499,6 @@ prefix_list_new(struct prefix_master* pm, struct symbol* sym, afi_t afi) return new ; } ; -/* Release given prefix_list -- assumes all contents of the prefix list have - * already been released... - * - * Unsets the symbol value and discards the prefix_list structure. - * Assumes that the contents of the prefix_list have already been emptied out. - */ -static void -prefix_list_free (struct prefix_list *plist) -{ - symbol_unset_value(plist->sym) ; - XFREE (MTYPE_PREFIX_LIST, plist) ; -} - /* Initialise prefix_list entry -- cleared to zeros. */ static struct prefix_list_entry * prefix_list_entry_init(struct prefix_list_entry * pe) @@ -541,6 +528,43 @@ prefix_dup_cache_free(struct prefix_master* pm) vector_reset(&pm->dup_cache, 0) ; } +/* Delete prefix_list from prefix_list_master and free it and its contents. */ +/* The prefix_list's symbol is set undefined. */ +static void +prefix_list_delete (struct prefix_list* plist) +{ + struct prefix_master* pm = plist->master ; + unsigned int i ; + struct prefix_list_entry* pe ; + + /* Free all the prefix_list_entries, then free the vector they live in. */ + for (VECTOR_ITEMS(&plist->list, pe, i)) + prefix_list_entry_free(pe) ; + vector_reset(&plist->list, 0) ; + + /* If there is a description, release that now. */ + if (plist->desc) + XFREE (MTYPE_TMP, plist->desc); + + /* Can no longer own the dup_cache. */ + if (pm->cache_owner == plist) + prefix_dup_cache_free(pm) ; + + /* Symbol no longer has a value & drop reference. */ + symbol_unset_value(plist->sym) ; + plist->sym = symbol_dec_ref(plist->sym) ; + + /* Finally, release the prefix_list structure. */ + XFREE (MTYPE_PREFIX_LIST, plist) ; + + /* No longer have a recently changed prefix-list */ + pm->recent = NULL ; + + /* Tell the world. */ + if (pm->delete_hook) + (*pm->delete_hook) (NULL); +} ; + /*============================================================================== * Operations on prefix_lists */ @@ -583,43 +607,6 @@ prefix_list_get (struct prefix_master* pm, const char *name, afi_t afi) return plist ? plist : prefix_list_new(pm, sym, afi) ; } ; -/* Delete prefix_list from prefix_list_master and free it and its contents. */ -/* The prefix_list's symbol is set undefined. */ -static void -prefix_list_delete (struct prefix_list* plist) -{ - struct prefix_master* pm = plist->master ; - unsigned int i ; - struct prefix_list_entry* pe ; - - /* Free all the prefix_list_entries, then free the vector they live in. */ - for (VECTOR_ITEMS(&plist->list, pe, i)) - prefix_list_entry_free(pe) ; - vector_reset(&plist->list, 0) ; - - /* If there is a description, release that now. */ - if (plist->desc) - XFREE (MTYPE_TMP, plist->desc); - - /* Can no longer own the dup_cache. */ - if (pm->cache_owner == plist) - prefix_dup_cache_free(pm) ; - - /* Symbol no longer has a value & drop reference. */ - symbol_unset_value(plist->sym) ; - plist->sym = symbol_dec_ref(plist->sym) ; - - /* Finally, release the prefix_list itself. */ - prefix_list_free(plist) ; - - /* No longer have a recently changed prefix-list */ - pm->recent = NULL ; - - /* Tell the world. */ - if (pm->delete_hook) - (*pm->delete_hook) (NULL); -} ; - /*============================================================================== * Operations on prefix_list_entry */ |