Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1419268

Re: [PATCH v8 4/5] perf config: Use zfree() instead of free() at perf_config_set__delete()

From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v8 4/5] perf config: Use zfree() instead of free() at perf_config_set__delete()
Date 2016-06-10 13:10 +0200
Message-ID <rIsu5-3Oy-19@gated-at.bofh.it> (permalink)
References <rHKW5-7x-3@gated-at.bofh.it> <rHKW5-7x-1@gated-at.bofh.it> <rI8lI-6YM-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 06/09/2016 10:37 PM, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jun 08, 2016 at 09:36:52PM +0900, Taeung Song escreveu:
>> perf_config_set__delete() delete allocated the config set
>> but the global variable 'config_set' is used all around.
>
>> So purge and zfree by an address of the global variable
>> , i.e. 'struct perf_config_set **' type
>> instead of using local variable 'set' of which type
>> is 'struct perf_config_set *'.
>
>> -void perf_config_set__delete(struct perf_config_set *set)
>> +void perf_config_set__delete(struct perf_config_set **set)
>>   {
>> -	if (set == NULL)
>> +	if (*set == NULL)
>>   		return;
>>
>> -	perf_config_set__purge(set);
>> -	free(set);
>> +	perf_config_set__purge(*set);
>> +	zfree(set);
>>   }
>
> Nope, don't change conventions like taht, a delete method should not
> receive a pointer to the pointer to be deleted, no odd cases, please.
>
> If you really think this is interesting, please introduce zdelete(),
> i.e.:
>
> void perf_config_set__zdelete(struct perf_config_set **set)
> {
> 	if (!set)
> 		return;
>
> 	perf_config_set__delete(*set);
> 	*set = NULL;
> }
>

I understood!

If we don't use the config set as a global variable,
it seems that we wouldn't need to change perf_config_set__delete() to 
perf_config_set__zdelete() as this patch.

Thanks,
Taeung

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH v8 4/5] perf config: Use zfree() instead of free() at perf_config_set__delete() Taeung Song <treeze.taeung@gmail.com> - 2016-06-08 14:40 +0200
  Re: [PATCH v8 4/5] perf config: Use zfree() instead of free() at  perf_config_set__delete() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-09 15:40 +0200
    Re: [PATCH v8 4/5] perf config: Use zfree() instead of free() at  perf_config_set__delete() Taeung Song <treeze.taeung@gmail.com> - 2016-06-10 13:10 +0200

csiph-web