On Fri, Dec 6, 2019 at 11:29 PM Han Zhou <[email protected]> wrote:
>
> Reuse xxx_clear() function in xxx_destroy() and remove redundant code.
>
> Signed-off-by: Han Zhou <[email protected]>

Looks good to me.

Acked-by: Dumitru Ceara <[email protected]>

> ---
>  lib/extend-table.c | 31 ++++++++++---------------------
>  1 file changed, 10 insertions(+), 21 deletions(-)
>
> diff --git a/lib/extend-table.c b/lib/extend-table.c
> index 77208fe..82dfcfa 100644
> --- a/lib/extend-table.c
> +++ b/lib/extend-table.c
> @@ -34,27 +34,6 @@ ovn_extend_table_init(struct ovn_extend_table *table)
>      hmap_init(&table->existing);
>  }
>
> -static void
> -ovn_extend_table_info_destroy(struct hmap *target)
> -{
> -    struct ovn_extend_table_info *e, *next;
> -    HMAP_FOR_EACH_SAFE (e, next, hmap_node, target) {
> -        hmap_remove(target, &e->hmap_node);
> -        free(e->name);
> -        free(e);
> -    }
> -    hmap_destroy(target);
> -}
> -
> -void
> -ovn_extend_table_destroy(struct ovn_extend_table *table)
> -{
> -    bitmap_free(table->table_ids);
> -
> -    ovn_extend_table_info_destroy(&table->desired);
> -    ovn_extend_table_info_destroy(&table->existing);
> -}
> -
>  /* Finds and returns a group_info in 'existing' whose key is identical
>   * to 'target''s key, or NULL if there is none. */
>  struct ovn_extend_table_info *
> @@ -91,6 +70,16 @@ ovn_extend_table_clear(struct ovn_extend_table *table, 
> bool existing)
>      }
>  }
>
> +void
> +ovn_extend_table_destroy(struct ovn_extend_table *table)
> +{
> +    ovn_extend_table_clear(table, false);
> +    hmap_destroy(&table->desired);
> +    ovn_extend_table_clear(table, true);
> +    hmap_destroy(&table->existing);
> +    bitmap_free(table->table_ids);
> +}
> +
>  /* Remove an entry from existing table */
>  void
>  ovn_extend_table_remove_existing(struct ovn_extend_table *table,
> --
> 2.1.0
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to