[PATCH v4 17/17] eal: add function attributes for allocation functions
Burakov, Anatoly
anatoly.burakov at intel.com
Wed Oct 2 10:42:30 CEST 2024
On 10/1/2024 5:25 PM, Stephen Hemminger wrote:
> On Tue, 1 Oct 2024 14:25:46 +0200
> David Marchand <david.marchand at redhat.com> wrote:
>
>> On Tue, Oct 1, 2024 at 2:21 PM Burakov, Anatoly
>> <anatoly.burakov at intel.com> wrote:
>>>> +
>>>> +/**
>>>> + * Frees the memory space pointed to by the provided pointer.
>>>> + *
>>>> + * This pointer must have been returned by a previous call to
>>>> + * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of
>>>> + * rte_free() is undefined if the pointer does not match this requirement.
>>>> + *
>>>> + * If the pointer is NULL, the function does nothing.
>>>> + *
>>>> + * @param ptr
>>>> + * The pointer to memory to be freed.
>>>> + */
>>>> +void
>>>> +rte_free(void *ptr);
>>>> +
>>>
>>> Is there any particular reason why rte_free was moved?
>>>
>>> Otherwise,
>>>
>>> Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
>>
>> I guess this is for the added annotation which points at rte_free symbol.
>> A forward declaration would be another option.
>
> Right, compiler now needs to know about the free function.
> Moving it was the clean solution and avoids duplication.
>
> If rte_free prototype is not moved...
>
> In file included from ../lib/eal/include/rte_string_fns.h:22,
> from ../lib/eal/common/eal_common_config.c:5:
> ../lib/eal/include/rte_common.h:261:42: error: ‘rte_free’ undeclared here (not in a function)
> 261 | #define __rte_dealloc_free __rte_dealloc(rte_free, 1)
> | ^~~~~~~~
> ../lib/eal/include/rte_common.h:260:31: note: in definition of macro ‘__rte_dealloc’
> 260 | __attribute__((malloc(dealloc, argno)))
> | ^~~~~~~
> ../lib/eal/include/rte_malloc.h:58:22: note: in expansion of macro ‘__rte_dealloc_free’
> 58 | __rte_malloc __rte_dealloc_free;
> | ^~~~~~~~~~~~~~~~~~
> [16/3024] Compiling C object lib/librte_telemetry.a.p/telemetry_telemetry.c.o
Makes sense, let's move the function then.
--
Thanks,
Anatoly
More information about the dev
mailing list