Re: [PATCH 05/15] name-rev: use sizeof(*ptr) instead of sizeof(type) in allocation
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Sep 20, 2019, 15:11 UTC
- Message-ID
- <cb35b779-79b1-e27d-e539-9ea9d2601b07@gmail.com>
- In-Reply-To
- <20190919214712.7348-6-szeder.dev@gmail.com>
On 9/19/2019 5:47 PM, SZEDER Gábor wrote:
Show 15 quoted lines
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
> builtin/name-rev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/name-rev.c b/builtin/name-rev.c
> index e406ff8e17..dec2228cc7 100644
> --- a/builtin/name-rev.c
> +++ b/builtin/name-rev.c
> @@ -98,7 +98,7 @@ static void name_rev(struct commit *commit,
> }
>
> if (name == NULL) {
> - name = xmalloc(sizeof(rev_name));
> + name = xmalloc(sizeof(*name));Is this our preferred way to use xmalloc()? If so, then I've been doing it wrong and will correct myself in the future.
-Stolee