chickadee » sdl2 » rw-from-string

rw-from-string strprocedure

Create a new sdl2:rwops that accesses the memory of the given CHICKEN Scheme string. You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

Signals an exception of kind (exn sdl2) if an error occurs.

Caution: Creating a sdl2:rwops from a string in CHICKEN-managed memory is unstable: the string might be garbage collected or moved in memory, which would break the sdl2:rwops. To be safe, you should object-evict the string and create the sdl2:rwops from the evicted string (not the original). You may wish to object-release the evicted string after you have closed the sdl2:rwops. Example:

(let* ((evicted-string (object-evict "..."))
       (rwops (sdl2:rw-from-string evicted-string))
       (surf (sdl2:load-bmp-rw rwops #t)))
  (object-release evicted-string)