I have been working in some C language function that is going to be called from a Progress 4GL application and I found myself with the following doubts:
The C function uses malloc to dynamically allocate an array of chars and the idea is that the pointer that allocates that memory will be returned to the Progress 4GL process which originally sent a MEMPTR data type to hold the result of the C method.
Basically the MEMPTR from Progress must be sent to the C function to "receive" the C generated array and use it when scope returns to it from de C function (a pass by reference between both languages where the C method "fills" the MEMPTR progress variable).
My questions is:
When the Progress process finishes and the MEMPTR variable is "freed", does it free the malloc allocated memory in the C function as well?
and
If I free the malloc allocated memory in the C function I m guessing the Progress process will receive garbage data, Is this correct?
Thanks for your time and help.
Greetings.