#define _GNU_SOURCE #include #include static scm_t_bits handlesmob_tag; void smobbug_init (void); SCM mark_handle (SCM x); SCM handlesmob_init () { SCM s_handlesmob; char *handle; handle = malloc (1); return SCM_NEWSMOB (s_handlesmob, handlesmob_tag, handle); } SCM mark_handlesmob (SCM x) { // No SCMs in the handle type: nothing to do here. return (SCM_BOOL_F); } size_t free_handlesmob (SCM handle) { SCM_ASSERT (SCM_SMOB_PREDICATE (handlesmob_tag, handle), handle, SCM_ARG1, "free-handlesmob"); char *m = SCM_SMOB_DATA (handle); if (m != NULL) free (m); return 0; } int print_handlesmob (SCM x, SCM port, scm_print_state *pstate) { char *frm = (char *) SCM_SMOB_DATA (x); char *str; scm_puts ("#", port); // non-zero means success return 1; } void smobbug_init () { handlesmob_tag = scm_make_smob_type ("handlesmob", sizeof (char *)); scm_set_smob_mark (handlesmob_tag, mark_handlesmob); scm_set_smob_free (handlesmob_tag, free_handlesmob); scm_set_smob_print (handlesmob_tag, print_handlesmob); scm_c_define_gsubr ("%handlesmob-init", 0, 0, 0, handlesmob_init); }