| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.5.3 Type checking
Functions that operate on smobs should check that the passed
SCM value indeed is a suitable smob before accessing its data.
They can do this with scm_assert_smob_type.
For example, here is a simple function that operates on an image smob, and checks the type of its argument.
SCM
clear_image (SCM image_smob)
{
int area;
struct image *image;
scm_assert_smob_type (image_tag, image_smob);
image = (struct image *) SCM_SMOB_DATA (image_smob);
area = image->width * image->height;
memset (image->pixels, 0, area);
/* Invoke the image's update function.
*/
if (scm_is_true (image->update_func))
scm_call_0 (image->update_func);
scm_remember_upto_here_1 (image_smob);
return SCM_UNSPECIFIED;
}
See Remembering During Operations for an explanation of the call
to scm_remember_upto_here_1.
This document was generated on February 3, 2012 using texi2html 5.0.
