These are chat archives for fourthbit/spheres
Spheres - A set of tools and libraries for real-life Scheme. Multiplatform and Mobile.
Hello! I'm having a curious problem with c structures. Here is a snippet:
(load (spheres/sdl2 sdl2)) (define (useless x) x) (let ((xoxo (alloc-SDL_Color))) (SDL_Color-r-set! xoxo #xff) (SDL_Color-g-set! xoxo #xff) (SDL_Color-b-set! xoxo #xff) (let loop () (useless (*->SDL_Color xoxo)) (loop)))
*->SDL_Color segfaults dereferencing a null pointer. It seems to me that xoxo gets garbage collected.
It happens, sooner or later, depending on memory pressure..
The only way to avoid this is to copy it (for example with another (let ((clone xoxo)) .. ) and then using the copy.
Is this the expected behavior?