Hi guys,

I'm using a very simple smob which only carries a pointer in the
immediate word.  It works fine, but what worries me is that the free
function seems never called.   Am I doing anything wrong?  What's the
standard way of making such kind of smob?

C++ code listed below:

--------------------------------------
static scm_t_bits model_smob_t;

static SCM make_model() {
    return scm_new_smob(model_smob_t, (scm_t_bits)(new MyModel()));
}

static size_t free_model(SCM smob) {
    cout << "free_model" << endl;
    void* ptr = (void*)SCM_SMOB_DATA(smob);
    delete (MyModel*)ptr;
}

...

model_smob_t = scm_make_smob_type("model", 0);  // shall I use zero here?
scm_set_smob_free(type, free_model);

...

--------------------------------------

Regards,
Sun Yijiang

Reply via email to