Out of curiosity, why are you doing so much work on the C side, rather than letting Scheme control everything? You could return an integer to Scheme here, which Scheme code could then wrap in the structure; it seems awfully indirect and a great deal more work than it's worth to do it from C, but perhaps I'm missing a better reason here.