[racket] An FFI question
The function that consumes a `_cairo_glyph_t-pointer` is passed an
array of glyphs, instead of a single one. It would be fine to add the
`#:malloc-mode 'atomic-interior` annotation, but that annotation will
have no effect on the one use, because the array is not allocated with
`make-cairo_glyph_t`.
At Sun, 7 Sep 2014 16:02:04 +0200, Jens Axel Søgaard wrote:
> Hi All,
>
> While reading the source of draw-lib/racket/draw/unsafe/cairo.rkt
> which contains the bindings of Cairo, I noticed the following note:
>
> ;; ALLOCATION NOTE: drawing to a Cairo surface might call back to
> ;; Racket, because a drawing suface might be a PDF or SVG file
> ;; that is written through a callback to Racket. Consequently,
> ;; all GC-allocated arguments to Cairo functions must be allocated
> ;; a 'atomic-interior, so that they do not move in case of a GC.
>
> This explains why _cairo_matrix_t is defined as:
>
> (define-cstruct _cairo_matrix_t ([xx _double*] [yx _double*] [xy
> _double*] [yy _double*] [x0 _double*] [y0 _double*])
> #:malloc-mode 'atomic-interior)
>
> However _cairo_glyph_t is defined as:
>
> (define-cstruct _cairo_glyph_t ([index _long] [x _double*] [y _double*]))
>
> Why is the #:malloc-mode 'atomic-interior not needed here?
>
> https://github.com/plt/racket/blob/c18f6e8d6dd2afc095be6764c8276b30f7c8da39/pkgs
> /draw-pkgs/draw-lib/racket/draw/unsafe/cairo.rkt#L16
>
> --
> Jens Axel Søgaard
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users