Jameson's point is that [LL] give you a pointer to the memory of a Julia array object which is then immediately not referred to by anything, meaning it can be garbage collected. Thus, you get a pointer which is immediately invalid. It will be ok to access until the next GC, but that can happen at any point in time – possibly immediately after taking its address.
On Sat, Feb 21, 2015 at 3:03 PM, Jameson Nash <[email protected]> wrote: > it doesn't matter what LL is. `pointer( [ anything ] )` will occasionally > cause segfaults or data corruption, because `[ anything ]` is more > complicated than just a variable name > > On Sat Feb 21 2015 at 2:51:46 PM J Luis <[email protected]> wrote: > >> LL is a linked list returned by C (thanks for your other pointer about >> linked lists) >> >> LL = GMT_Create_Options(API, 0, r); >> >> sábado, 21 de Fevereiro de 2015 às 19:11:37 UTC, Jameson escreveu: >>> >>> Note that in your code `pointer([LL])` will occasionally cause a >>> segfault. The argument to `pointer` must be simply a variable name, not an >>> expression. >>> >> (i'm working a PR to eliminate the need for `pointer`, since I believe >>> that it is hard to use correctly: https://github.com/JuliaLang/ >>> julia/blob/jn/ccall3/doc/manual/calling-c-and-fortran- >>> code.rst#passing-pointers-for-modifying-inputs) >>> >> >>> On Sat Feb 21 2015 at 1:29:58 PM J Luis <[email protected]> wrote: >>> >>>> Thanks. That was exactly it. >>>> >>>> sábado, 21 de Fevereiro de 2015 às 18:20:05 UTC, Steven G. Johnson >>>> escreveu: >>>> >>>>> Make sure GMT.GMT_RESOURCE is declared as an immutable type if you >>>>> want Array{GMT.GMT_RESOURCE} to correspond to the memory layout of an >>>>> array >>>>> of C structs. >>>>> >>>>
