> El jue., 9 ene. 2020 a las 7:41, ToddAndMargo via perl6-users
> (<perl6-us...@perl.org <mailto:perl6-us...@perl.org>>) escribió:
>
> On 2020-01-08 22:03, ToddAndMargo via perl6-users wrote:
> > On 2020-01-08 21:05, ToddAndMargo via perl6-users wrote:
> >> Hi All,
> >>
> >> Does Raku's NativeCall run WinAPI's "LocalFree( )" after it
creates
> >> buffers? Or do I need to do it myself?
> >>
> >>
>
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-localfree
>
> >>
> >>
> >> Many thanks,
> >> -T
> >
> >
> > I am doing it anyway. It is not throwing an error.
> > This may be a bug in NativeCall, resulting in a memory
> > leak
>
>
> Follow up:
>
> NativeCall does not close any WinApi call buffers, so
> you need to do it yourself.
> On 2020-01-08 22:52, JJ Merelo wrote:
Which is what I told you twice as an answer to your question:
https://stackoverflow.com/questions/59630605/does-rakus-nativecall-run-localfree.
Also, documentation:
https://docs.raku.org/language/nativecall#index-entry-nativecall
"Call into dynamic libraries that follow the C calling convention"
From where it follows: NativeCall does not call anything for you,
WinApi calls or otherwise. If what you do is call into dynamic libraries
that follow the C calling convention, it will help you do that. Nothing
more (and nothing less).
JJ
Hi JJ,
There was a lot of very helpful folks over there,
including you, even if they did misunderstand
my question. I think it was because they misjudged
that I wanted help with calling RegSetValueExW and
not help with the clean up after the call.
There is a lot more than "Nothing more (and nothing less)"
going on. For one, NativeCall is converting Raku
structure into C pointers and converts values pointed
to by C pointers back into Raku structures. For
another, when Native call is little endian integers
it gets from Raku, but does not convert back in the
process.
And none of this is explained in the documentation.
As you have said previous, it is up to the student
to figure it out on his own. I am up to 390
line in my paper on the subject. I have still
to go with documenting how to match up NativeCall
declarations with C declarations with examples.
You would think that Native Call would release any buffers
it created in the process. That is still unanswered.
LocalFree on the other hand, is freeing buffers/memory
used on the dll side. I call LocalFree whether it
needs it or not. Does not hurt anything if not needed.
It looks at your handle and decided what to do from there
-T