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; |
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 |
|
|
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 |