[pacman-dev] [PATCH] Add a helper macro to free() dload_payload structure
Allan McRae
allan at archlinux.org
Sun Apr 26 23:54:40 UTC 2020
On 24/4/20 2:40 pm, Anatol Pomozov wrote:
> It frees all the dynamically allocated fields plus the struct itself
>
How many times will you use this? Across how many functions?
We usually #unset defines not used globally too.
> Signed-off-by: Anatol Pomozov <anatol.pomozov at gmail.com>
> ---
> lib/libalpm/dload.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h
> index a40b51b7..3f2fb9ea 100644
> --- a/lib/libalpm/dload.h
> +++ b/lib/libalpm/dload.h
> @@ -56,6 +56,11 @@ void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload);
> int _alpm_download(struct dload_payload *payload, const char *localpath,
> char **final_file, const char **final_url);
>
> +#define DLOAD_PAYLOAD_FREE(payload) { \
> + _alpm_dload_payload_reset(payload); \
> + FREE(payload); \
> +}
> +
> int _alpm_multi_download(alpm_handle_t *handle,
> alpm_list_t *payloads /* struct dload_payload */,
> const char *localpath);
>
More information about the pacman-dev
mailing list