Re: [PATCH 03/10] Make target_desc::features an std::vector

Yao Qi
2017-11-02T09:29:43Z

Simon Marchi <simon.marchi@ericsson.com> writes:

Patch is good to me, two comments below,

> +typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
>
> /* A target description. */
>
> @@ -393,17 +394,7 @@ struct target_desc : tdesc_element
> target_desc ()
> {}
>
> - virtual ~target_desc ()
> - {
> - struct tdesc_feature *feature;
> - int ix;
> -
> - for (ix = 0;
> - VEC_iterate (tdesc_feature_p, features, ix, feature);
> - ix++)
> - delete feature;
> - VEC_free (tdesc_feature_p, features);
> - }
> + virtual ~target_desc () = default;
>

Can't we remove this line and use default (compiler generated)
dtor?

> target_desc (const target_desc &) = delete;
> void operator= (const target_desc &) = delete;
> @@ -422,17 +413,13 @@ struct target_desc : tdesc_element
> std::vector<property> properties;
>
> /* The features associated with this target. */
> - VEC(tdesc_feature_p) *features = NULL;
> + std::vector<std::unique_ptr<tdesc_feature>> features;
>

std::vector<tdesc_feature_up> features;

shorten the code.

--
Yao (齐尧)