[fpc-pascal] Re: Passing objects to libraries and back
Jonas Maebe
jonas.maebe at elis.ugent.be
Sat Feb 26 11:33:29 CET 2011
On 26 Feb 2011, at 11:15, Michael Van Canneyt wrote:
> On Fri, 25 Feb 2011, leledumbo wrote:
>
>>> can i pass ansistrings ?
>>
>> Yes, but only if you know what you're doing. NEVER modify the passed strings
>> (it would confuse the reference counting). Use const parameter all the time.
>
> It will almost certainly lead to memory leaks, because a simple
> a:=b;
> inside the library with b passed on from the main program, will lead to problems as soon as the library is unloaded.
It shouldn't matter with cmem/sharemem, because
a) unloading a library from within one of its own routines is not possible, so there cannot be any local variables in the shared libraries holding a reference at such a point
b) global variables are finalised when the library is unloaded
Jonas
More information about the fpc-pascal
mailing list