[PATCH] wget: release the globals struct memory pointed by ptr_to_globals.

Guilherme Maciel Ferreira guilherme.maciel.ferreira at gmail.com
Fri Mar 22 17:02:24 UTC 2013


2013/3/21 Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>:
> On 21 March 2013 20:14:04 Guilherme Maciel Ferreira
> <guilherme.maciel.ferreira at gmail.com> wrote:
>>
>> Hi,
>
>
>> >> +#if ENABLE_FEATURE_WGET_LONG_OPTIONS
>> >> +       if (ENABLE_FEATURE_CLEAN_UP && G.extra_headers) {
>> >
>> >
>> > The idea behind these ENABLE defines was to increase preprocessor
>> > coverage.
>> > You should likely move the condition from CPP to c.
>>
>> I not sure if I understood exactly what you mean here. Did you mean to
>> add the ENABLE_FEATURE_CLEAN_UP to the preprocessor condition, like
>> this:
>>
>> #if ENABLE_FEATURE_WGET_LONG_OPTIONS && ENABLE_FEATURE_CLEAN_UP
>>         if (G.extra_headers) {
>>                 free(G.extra_headers);
>>         }
>> #endif
>
>
> No, the other way round:
>
>>
>> or, on the other hand, by the second sentence I understood you meant
>> to do not use the preprocessor:
>>
>> if (ENABLE_FEATURE_WGET_LONG_OPTIONS && ENABLE_FEATURE_CLEAN_UP &&
>> G.extra_headers) {
>>         free(G.extra_headers);
>> }
>
>
> Exactly. Sorry that I wasn't clear.
> TIA,
>

The extra_headers member declaration depends on
ENABLE_FEATURE_WGET_LONG_OPTIONS:

/* Globals */
struct globals {
	...
#if ENABLE_FEATURE_WGET_LONG_OPTIONS
        char *post_data;
        char *extra_headers;
#endif
        ...
} FIX_ALIASING;

thus, the free(G.extra_headers) statement must be stripped off by
preprocessor if ENABLE_FEATURE_WGET_LONG_OPTIONS is zero. May I keep
on with the previous approach, or do you have another one in mind?

Best regards,

-- 
Guilherme Maciel Ferreira
Mobile Brazil: +55 48 9904 3728 e +55 48 9134 4651
Site: http://guilhermemacielferreira.com/
Skype: guilherme.maciel.ferreira


More information about the busybox mailing list