[Jprogramming] is result of 15!:14 permanent?
Elijah Stone
elronnd at elronnd.net
Tue Jul 18 06:34:34 UTC 2023
Its address will not change. It will stick around until it is explicitly
freed (it could be freed by you with memf or by a c library with free). I had
vague plans to implement something that could be freed automatically, but have
not done so yet. However, depending on usage, you could pass in a j array
instead (character array with the appropriate length), which would avoid the
need to free manually.
On Tue, 18 Jul 2023, Igor Zhuravlov wrote:
> To prepare some structure as argument to DLL call, a memory should be
> allocated by mema before call, and freed by memf after use. So that
> structure's life cycle is under the manual control.
>
> I want to delegate this care to JE, something like this:
>
> struct=. SIZEOF # ' ' NB. equiv. to:
> addr=. 15!:14 < 'struct' NB. struct=. mema SIZEOF
> NB. fill the struct...
> SIGNATURE 15!:0 < < addr NB. call DLL with addr as a sole parameter
> return. NB. let JE to do (memf addr) implicitly
>
> But the question here is: does JE keep the result of (15!:14 < 'struct')
> permanent? Or situations are possible when a noun's data address can change
> (GC, unaliasing etc)?
>
> --
> Regards,
> Igor
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list