/[guile]/guile/guile-core/doc/example-smob/image-type.c
ViewVC logotype

Diff of /guile/guile-core/doc/example-smob/image-type.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mgrabmue, Wed May 30 20:28:51 2001 UTC revision 1.8 by mvo, Thu Feb 28 20:55:49 2002 UTC
# Line 21  Line 21 
21  #include <stdlib.h>  #include <stdlib.h>
22  #include <libguile.h>  #include <libguile.h>
23    
24  static scm_bits_t image_tag;  static scm_t_bits image_tag;
25    
26  struct image {  struct image {
27    int width, height;    int width, height;
# Line 49  make_image (SCM name, SCM s_width, SCM s Line 49  make_image (SCM name, SCM s_width, SCM s
49    width = SCM_INUM (s_width);    width = SCM_INUM (s_width);
50    height = SCM_INUM (s_height);    height = SCM_INUM (s_height);
51        
52    image = (struct image *) scm_must_malloc (sizeof (struct image), "image");    image = (struct image *) scm_gc_malloc (sizeof (struct image), "image");
53    image->width = width;    image->width = width;
54    image->height = height;    image->height = height;
55    image->pixels = scm_must_malloc (width * height, "image pixels");    image->pixels = scm_gc_malloc (width * height, "image pixels");
56    image->name = name;    image->name = name;
57    image->update_func = SCM_BOOL_F;    image->update_func = SCM_BOOL_F;
58    
# Line 93  static size_t Line 93  static size_t
93  free_image (SCM image_smob)  free_image (SCM image_smob)
94  {  {
95    struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);    struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);
   size_t size = image->width * image->height + sizeof (struct image);  
96    
97    free (image->pixels);    scm_gc_free (image->pixels, image->width * image->height, "image pixels");
98    free (image);    scm_gc_free (image, sizeof (struct image), "image");
99    
100    return size;    return 0;
101  }  }
102    
103  static int  static int

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26