Mercurial > emacs
comparison src/xfns.c @ 28410:2812a333e746
(free_image_cache): Free the cache structure itself
last, after all its members have been freed.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 30 Mar 2000 09:27:30 +0000 |
parents | 11d7a6fdad5f |
children | cad4cc0508a0 |
comparison
equal
deleted
inserted
replaced
28409:4a7f44c0b33d | 28410:2812a333e746 |
---|---|
5381 xassert (c->refcount == 0); | 5381 xassert (c->refcount == 0); |
5382 | 5382 |
5383 for (i = 0; i < c->used; ++i) | 5383 for (i = 0; i < c->used; ++i) |
5384 free_image (f, c->images[i]); | 5384 free_image (f, c->images[i]); |
5385 xfree (c->images); | 5385 xfree (c->images); |
5386 xfree (c->buckets); | |
5386 xfree (c); | 5387 xfree (c); |
5387 xfree (c->buckets); | |
5388 FRAME_X_IMAGE_CACHE (f) = NULL; | 5388 FRAME_X_IMAGE_CACHE (f) = NULL; |
5389 } | 5389 } |
5390 } | 5390 } |
5391 | 5391 |
5392 | 5392 |
5839 bitmap. | 5839 bitmap. |
5840 | 5840 |
5841 Both the file and data forms may contain the additional entries | 5841 Both the file and data forms may contain the additional entries |
5842 `:background COLOR' and `:foreground COLOR'. If not present, | 5842 `:background COLOR' and `:foreground COLOR'. If not present, |
5843 foreground and background of the frame on which the image is | 5843 foreground and background of the frame on which the image is |
5844 displayed, is used. */ | 5844 displayed is used. */ |
5845 | 5845 |
5846 static int | 5846 static int |
5847 xbm_image_p (object) | 5847 xbm_image_p (object) |
5848 Lisp_Object object; | 5848 Lisp_Object object; |
5849 { | 5849 { |
6109 nbytes = bytes_per_line * *height; | 6109 nbytes = bytes_per_line * *height; |
6110 p = *data = (char *) xmalloc (nbytes); | 6110 p = *data = (char *) xmalloc (nbytes); |
6111 | 6111 |
6112 if (v10) | 6112 if (v10) |
6113 { | 6113 { |
6114 | |
6115 for (i = 0; i < nbytes; i += 2) | 6114 for (i = 0; i < nbytes; i += 2) |
6116 { | 6115 { |
6117 int val = value; | 6116 int val = value; |
6118 expect (XBM_TK_NUMBER); | 6117 expect (XBM_TK_NUMBER); |
6119 | 6118 |
7955 { | 7954 { |
7956 struct jpeg_error_mgr pub; | 7955 struct jpeg_error_mgr pub; |
7957 jmp_buf setjmp_buffer; | 7956 jmp_buf setjmp_buffer; |
7958 }; | 7957 }; |
7959 | 7958 |
7959 | |
7960 static void | 7960 static void |
7961 my_error_exit (cinfo) | 7961 my_error_exit (cinfo) |
7962 j_common_ptr cinfo; | 7962 j_common_ptr cinfo; |
7963 { | 7963 { |
7964 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; | 7964 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; |
7965 longjmp (mgr->setjmp_buffer, 1); | 7965 longjmp (mgr->setjmp_buffer, 1); |
7966 } | 7966 } |
7967 | |
7967 | 7968 |
7968 /* Init source method for JPEG data source manager. Called by | 7969 /* Init source method for JPEG data source manager. Called by |
7969 jpeg_read_header() before any data is actually read. See | 7970 jpeg_read_header() before any data is actually read. See |
7970 libjpeg.doc from the JPEG lib distribution. */ | 7971 libjpeg.doc from the JPEG lib distribution. */ |
7971 | 7972 |
8327 size_t len; | 8328 size_t len; |
8328 int index; | 8329 int index; |
8329 } | 8330 } |
8330 tiff_memory_source; | 8331 tiff_memory_source; |
8331 | 8332 |
8333 | |
8332 static size_t | 8334 static size_t |
8333 tiff_read_from_memory (data, buf, size) | 8335 tiff_read_from_memory (data, buf, size) |
8334 thandle_t data; | 8336 thandle_t data; |
8335 tdata_t buf; | 8337 tdata_t buf; |
8336 tsize_t size; | 8338 tsize_t size; |
8342 bcopy (src->bytes + src->index, buf, size); | 8344 bcopy (src->bytes + src->index, buf, size); |
8343 src->index += size; | 8345 src->index += size; |
8344 return size; | 8346 return size; |
8345 } | 8347 } |
8346 | 8348 |
8349 | |
8347 static size_t | 8350 static size_t |
8348 tiff_write_from_memory (data, buf, size) | 8351 tiff_write_from_memory (data, buf, size) |
8349 thandle_t data; | 8352 thandle_t data; |
8350 tdata_t buf; | 8353 tdata_t buf; |
8351 tsize_t size; | 8354 tsize_t size; |
8352 { | 8355 { |
8353 return (size_t) -1; | 8356 return (size_t) -1; |
8354 } | 8357 } |
8358 | |
8355 | 8359 |
8356 static toff_t | 8360 static toff_t |
8357 tiff_seek_in_memory (data, off, whence) | 8361 tiff_seek_in_memory (data, off, whence) |
8358 thandle_t data; | 8362 thandle_t data; |
8359 toff_t off; | 8363 toff_t off; |
8385 | 8389 |
8386 src->index = idx; | 8390 src->index = idx; |
8387 return src->index; | 8391 return src->index; |
8388 } | 8392 } |
8389 | 8393 |
8394 | |
8390 static int | 8395 static int |
8391 tiff_close_memory (data) | 8396 tiff_close_memory (data) |
8392 thandle_t data; | 8397 thandle_t data; |
8393 { | 8398 { |
8394 /* NOOP */ | 8399 /* NOOP */ |
8395 return 0; | 8400 return 0; |
8396 } | 8401 } |
8402 | |
8397 | 8403 |
8398 static int | 8404 static int |
8399 tiff_mmap_memory (data, pbase, psize) | 8405 tiff_mmap_memory (data, pbase, psize) |
8400 thandle_t data; | 8406 thandle_t data; |
8401 tdata_t *pbase; | 8407 tdata_t *pbase; |
8403 { | 8409 { |
8404 /* It is already _IN_ memory. */ | 8410 /* It is already _IN_ memory. */ |
8405 return 0; | 8411 return 0; |
8406 } | 8412 } |
8407 | 8413 |
8414 | |
8408 static void | 8415 static void |
8409 tiff_unmap_memory (data, base, size) | 8416 tiff_unmap_memory (data, base, size) |
8410 thandle_t data; | 8417 thandle_t data; |
8411 tdata_t base; | 8418 tdata_t base; |
8412 toff_t size; | 8419 toff_t size; |
8413 { | 8420 { |
8414 /* We don't need to do this. */ | 8421 /* We don't need to do this. */ |
8415 } | 8422 } |
8416 | 8423 |
8424 | |
8417 static toff_t | 8425 static toff_t |
8418 tiff_size_of_memory (data) | 8426 tiff_size_of_memory (data) |
8419 thandle_t data; | 8427 thandle_t data; |
8420 { | 8428 { |
8421 return ((tiff_memory_source *) data)->len; | 8429 return ((tiff_memory_source *) data)->len; |
8422 } | 8430 } |
8431 | |
8423 | 8432 |
8424 /* Load TIFF image IMG for use on frame F. Value is non-zero if | 8433 /* Load TIFF image IMG for use on frame F. Value is non-zero if |
8425 successful. */ | 8434 successful. */ |
8426 | 8435 |
8427 static int | 8436 static int |
8610 gif_load, | 8619 gif_load, |
8611 x_clear_image, | 8620 x_clear_image, |
8612 NULL | 8621 NULL |
8613 }; | 8622 }; |
8614 | 8623 |
8624 | |
8615 /* Return non-zero if OBJECT is a valid GIF image specification. */ | 8625 /* Return non-zero if OBJECT is a valid GIF image specification. */ |
8616 | 8626 |
8617 static int | 8627 static int |
8618 gif_image_p (object) | 8628 gif_image_p (object) |
8619 Lisp_Object object; | 8629 Lisp_Object object; |
8628 | 8638 |
8629 /* Must specify either the :data or :file keyword. */ | 8639 /* Must specify either the :data or :file keyword. */ |
8630 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; | 8640 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; |
8631 } | 8641 } |
8632 | 8642 |
8643 | |
8633 /* Reading a GIF image from memory | 8644 /* Reading a GIF image from memory |
8634 Based on the PNG memory stuff to a certain extent. */ | 8645 Based on the PNG memory stuff to a certain extent. */ |
8635 | 8646 |
8636 typedef struct | 8647 typedef struct |
8637 { | 8648 { |
8638 unsigned char *bytes; | 8649 unsigned char *bytes; |
8639 size_t len; | 8650 size_t len; |
8640 int index; | 8651 int index; |
8641 } | 8652 } |
8642 gif_memory_source; | 8653 gif_memory_source; |
8654 | |
8643 | 8655 |
8644 /* Make the current memory source available to gif_read_from_memory. | 8656 /* Make the current memory source available to gif_read_from_memory. |
8645 It's done this way because not all versions of libungif support | 8657 It's done this way because not all versions of libungif support |
8646 a UserData field in the GifFileType structure. */ | 8658 a UserData field in the GifFileType structure. */ |
8647 static gif_memory_source *current_gif_memory_src; | 8659 static gif_memory_source *current_gif_memory_src; |
9745 break; | 9757 break; |
9746 | 9758 |
9747 /* Let the row go over the full width of the frame. */ | 9759 /* Let the row go over the full width of the frame. */ |
9748 row->full_width_p = 1; | 9760 row->full_width_p = 1; |
9749 | 9761 |
9750 /* There's a glyph at the end of rows that is use to place | 9762 /* There's a glyph at the end of rows that is used to place |
9751 the cursor there. Don't include the width of this glyph. */ | 9763 the cursor there. Don't include the width of this glyph. */ |
9752 if (row->used[TEXT_AREA]) | 9764 if (row->used[TEXT_AREA]) |
9753 { | 9765 { |
9754 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | 9766 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; |
9755 row_width = row->pixel_width - last->pixel_width; | 9767 row_width = row->pixel_width - last->pixel_width; |