28 |
#include <unistd.h> |
#include <unistd.h> |
29 |
#endif |
#endif |
30 |
|
|
31 |
|
#ifdef BOEHM_GC |
32 |
|
#include <gc.h> |
33 |
|
#endif |
34 |
|
|
35 |
/* This makes the fields of a Display accessible, in Xlib header files. */ |
/* This makes the fields of a Display accessible, in Xlib header files. */ |
36 |
|
|
37 |
#define XLIB_ILLEGAL_ACCESS |
#define XLIB_ILLEGAL_ACCESS |
4527 |
Lisp_Object spec; |
Lisp_Object spec; |
4528 |
unsigned hash; |
unsigned hash; |
4529 |
{ |
{ |
4530 |
struct image *img = (struct image *) xmalloc (sizeof *img); |
struct image *img = (struct image *) XGC_CALLOC (1, sizeof *img); |
4531 |
|
|
4532 |
xassert (valid_image_p (spec)); |
xassert (valid_image_p (spec)); |
|
bzero (img, sizeof *img); |
|
4533 |
img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); |
img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); |
4534 |
xassert (img->type != NULL); |
xassert (img->type != NULL); |
4535 |
img->spec = spec; |
img->spec = spec; |
4564 |
|
|
4565 |
/* Free resources, then free IMG. */ |
/* Free resources, then free IMG. */ |
4566 |
img->type->free (f, img); |
img->type->free (f, img); |
4567 |
xfree (img); |
XGC_FREE (img); |
4568 |
} |
} |
4569 |
} |
} |
4570 |
|
|
4824 |
|
|
4825 |
|
|
4826 |
/* Return a new, initialized image cache that is allocated from the |
/* Return a new, initialized image cache that is allocated from the |
4827 |
heap. Call free_image_cache to free an image cache. */ |
heap. Call free_image_cache to free an image in the cache. */ |
4828 |
|
|
4829 |
struct image_cache * |
struct image_cache * |
4830 |
make_image_cache () |
make_image_cache () |
4831 |
{ |
{ |
4832 |
struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); |
struct image_cache *c = (struct image_cache *) XGC_CALLOC (1, sizeof *c); |
4833 |
int size; |
int size; |
4834 |
|
|
|
bzero (c, sizeof *c); |
|
4835 |
c->size = 50; |
c->size = 50; |
4836 |
c->images = (struct image **) xmalloc (c->size * sizeof *c->images); |
c->images = (struct image **) XGC_MALLOC (c->size * sizeof *c->images); |
4837 |
size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
4838 |
c->buckets = (struct image **) xmalloc (size); |
c->buckets = (struct image **) XGC_MALLOC_ATOMIC (size); |
4839 |
bzero (c->buckets, size); |
bzero (c->buckets, size); |
4840 |
return c; |
return c; |
4841 |
} |
} |
4842 |
|
|
4843 |
|
|
4844 |
/* Free image cache of frame F. Be aware that X frames share images |
/* Free image cache of frame F. Be aware that X frames share image |
4845 |
caches. */ |
caches. */ |
4846 |
|
|
4847 |
void |
void |
4858 |
|
|
4859 |
for (i = 0; i < c->used; ++i) |
for (i = 0; i < c->used; ++i) |
4860 |
free_image (f, c->images[i]); |
free_image (f, c->images[i]); |
4861 |
xfree (c->images); |
XGC_FREE (c->images); |
4862 |
xfree (c->buckets); |
XGC_FREE (c->buckets); |
4863 |
xfree (c); |
XGC_FREE (c); |
4864 |
FRAME_X_IMAGE_CACHE (f) = NULL; |
FRAME_X_IMAGE_CACHE (f) = NULL; |
4865 |
} |
} |
4866 |
} |
} |
5165 |
if (i == c->used && c->used == c->size) |
if (i == c->used && c->used == c->size) |
5166 |
{ |
{ |
5167 |
c->size *= 2; |
c->size *= 2; |
5168 |
c->images = (struct image **) xrealloc (c->images, |
c->images = (struct image **) XGC_REALLOC (c->images, |
5169 |
c->size * sizeof *c->images); |
c->size * sizeof *c->images); |
5170 |
} |
} |
5171 |
|
|
5172 |
/* Add IMG to c->images, and assign IMG an id. */ |
/* Add IMG to c->images, and assign IMG an id. */ |