[pacman-dev] [PATCH] Convert payload structs from heap allocated to stack allocated
Allan McRae
allan at archlinux.org
Wed Feb 12 08:36:53 UTC 2020
On 10/2/20 9:55 am, Anatol Pomozov wrote:
> download_files() dynamically allocates a payload object for each
> package. Then iterates over these payloads and calls
> download_single_file() for it.
>
> This code can be simplified to iterate over package list itself.
> payload struct can be stack allocated in this case.
>
> Signed-off-by: Anatol Pomozov <anatol.pomozov at gmail.com>
> ---
This patch looks fine (minor change below).
However, the change from heap to stack allocated is rather unimportant.
Your commit message should highlight what the patch achieves. E.g.
Simplify construction of payloads in download_files
Currently, download_files() creates payloads for all packages then
iterates over them, calling download_single_file. This can be
simplified by looping over packages and constructing the payload as needed.
Saying that... it is really a limited simplification. I assume this
makes implementing parallel downloads easier later on. If so, state
that too.
<snip>
> + if(files)
> + alpm_list_free(files);
Note we keep the surrounding brackets even for single line statements.
Allan
More information about the pacman-dev
mailing list