Progress 4L SET-SIZE statement and C - malloc
We have a Shared Library that allocates ( using malloc ) memory for a char array which is returned via a MEMPTR to a Progress procedure.
In an OpenEdge manual I read that to free a Progress MEMPTR it is nec开发者_Python百科essary to use the SET-SIZE statement and set it to zero (0) .
So my question is, by doing this:
SET-SIZE(mem-pointer) = 0.
the memory of the returned array allocated with malloc in the SL is freed as well?
If it isn't the case, Can I create a function that after the Progress Process finishes frees the C allocated memory?
And finally if I have to create this function, can anyone point me in some direction, reference manual or tutorial?
Best practice is "you create it, you delete it". So your C code should clean it up at the appropriate time. And then do the set-size(0) in the 4GL code.
Documentation is in the ABL "Programming Interfaces" manual. They are all online at http://communities.progress.com/pcom/docs/DOC-16074
The chapter that you want is:
http://documentation.progress.com/output/OpenEdge102b/oe102bhtml/wwhelp/wwhimpl/js/html/wwhelp.htm#href=dvpin/15dvpinch08epi.17.1.html
I'm not familiar with Progress, but it seems like you could make a dealloc function in your c library that takes the MEMPTR, frees the malloced memory, and after calling it from Progress, free the MEMPTR in Progress. If you had access to the MEMPTR in the first c function, you should be able to access it in a dealloc function.
精彩评论