- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Sir,
Is it OK to use malloc() function in iLLD code?
It is needed to free it to avoid memory leak,
besides that, is there any to note?Thanks.
Solved! Go to Solution.
- Labels:
-
Aurix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi John,
iLLD is Infineon Low Level Driver. It does not provide the implementation of memory management function (e.g. malloc). It is implemented by other software component.
For your question, it depends on the design of memory management function. Therefore, user needs to refer to user manual of the memory management function. The user manual may have information on how to use those functions to allow memory issue.
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello John,
Would you explain more about your concern? Besides, would you provide a use case of using malloc() function in ILLD code you want to discuss?
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ken,
Because "malloc" only found once in this function,
My use case is
Variable array is handled with inside my function. And malloc() is be used to allocate a variable memory, free() is used to return the memory to heap before exiting function.
Just want to know, after many times malloc and free, there is no memory leak to cause out of memory issue. Thanks.
Ifx_Fifo *Ifx_Fifo_create(Ifx_SizeT size, Ifx_SizeT elementSize)
{
Ifx_Fifo *fifo = NULL_PTR;
size = Ifx_AlignOn32(size); /* data transfer is optimised for 32 bit access */
fifo = malloc(size + sizeof(Ifx_Fifo) + 8); /* +8 because of padding in case the pointer is not aligned on 64 */
if (IFX_VALIDATE(IFX_VERBOSE_LEVEL_ERROR, (fifo != NULL_PTR)))
{
fifo = Ifx_Fifo_init(fifo, size, elementSize);
}
return fifo;
}
void Ifx_Fifo_destroy(Ifx_Fifo *fifo)
{
free(fifo);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi John,
iLLD is Infineon Low Level Driver. It does not provide the implementation of memory management function (e.g. malloc). It is implemented by other software component.
For your question, it depends on the design of memory management function. Therefore, user needs to refer to user manual of the memory management function. The user manual may have information on how to use those functions to allow memory issue.
Ken