guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: smob pointer moving


From: Noah Roberts
Subject: Re: smob pointer moving
Date: Sat, 01 Feb 2003 22:56:44 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020605

Steve Tell wrote:

SCM db_open(SCM obj)
{
 Database *db = DB(db);

I think you mean DB(obj) above.   Typo in email, or perhaps your real
problem?

Actually it looks like it was very possibly a typo in code. The argument was named db to begin with and I had decided to change it in favor of having that name for the converted variable - probably forgot to change the above. Pretty embarasing actually :P

One other thing wrong that I see here: You're not checking that obj really is a database smob before casting it and chasing the
(possibly random) pointer.

Yeah, I hadn't gotten to that part in my searching - seems that finding thurough information on guile is a bit tough. It is all out there, but scattered between various mailing lists, info pages, tutorials, and of course the source code itself, but I am beginning to get all the parts I require mapped out.

(recent docs indicate that SCM_SMOB_PREDICATE() and SCM_ASSERT() are
available for this, probably a better choice.)

That is what I found and preliminary testing indicates that it is what is "supposed" to be used....
SCM_ASSERT(SCM_SMOB_PREDICATE(db_id, obj), obj, SCM_ARG1, "db-open");

It was actually in this document that I found SCM_SMOB_DATA as well.

printf("Database is at %p\n", db); db->open();
 printf("db_open called.\n");
 return SCM_EOL;
}

Thanks for the info, it looks like it was plain sloppyness and not missinformation or lack of understanding that caused my problem. After seing what caused the error I think it best to use SCM_SMOB_DATA in all cases so that my code is not relying on a specific implementation of smobs in case they change in later releases. That probably won't happen, but better to use the existing macro than to make up my own, I just have to know about them first :P

Thanks,
NR





reply via email to

[Prev in Thread] Current Thread [Next in Thread]