aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-08-19 17:51:35 -0700
committerPaul Eggert2013-08-19 17:51:35 -0700
commit8c2f38aaab7a7a2f0605416fc2ee38701e41ab61 (patch)
treee195b310caf03b098d9e3b25776ecf17ca05c31c /src
parentbb566ceafe3230d55923cb3043c3b231e4b9c0f9 (diff)
downloademacs-8c2f38aaab7a7a2f0605416fc2ee38701e41ab61.tar.gz
emacs-8c2f38aaab7a7a2f0605416fc2ee38701e41ab61.zip
* image.c (SIGNATURE_DIGESTSIZE): Remove.
(struct animation_cache): Make signature a flexible array member. All uses changed. This is a tad slower but may insulate us better from future changes to ImageMagick.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/image.c15
2 files changed, 13 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d0bafd3914e..e21d82bdc09 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12013-08-20 Paul Eggert <eggert@cs.ucla.edu>
2
3 * image.c (SIGNATURE_DIGESTSIZE): Remove.
4 (struct animation_cache): Make signature a flexible array member.
5 All uses changed. This is a tad slower but may insulate us better
6 from future changes to ImageMagick.
7
12013-08-19 Paul Eggert <eggert@cs.ucla.edu> 82013-08-19 Paul Eggert <eggert@cs.ucla.edu>
2 9
3 * image.c: Shrink memory needed for animation cache. 10 * image.c: Shrink memory needed for animation cache.
diff --git a/src/image.c b/src/image.c
index 4970d40af33..2db44d07c81 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7876,17 +7876,13 @@ imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent])
7876 separate from the image cache, because the images may be scaled 7876 separate from the image cache, because the images may be scaled
7877 before display. */ 7877 before display. */
7878 7878
7879/* Size of ImageMagick image signatures, in bytes. It's SHA-256 as a
7880 hex string, so it's 256 bits represented via 4 bits per byte. */
7881enum { SIGNATURE_DIGESTSIZE = 256 / 4 };
7882
7883struct animation_cache 7879struct animation_cache
7884{ 7880{
7885 MagickWand *wand; 7881 MagickWand *wand;
7886 int index; 7882 int index;
7887 EMACS_TIME update_time; 7883 EMACS_TIME update_time;
7888 struct animation_cache *next; 7884 struct animation_cache *next;
7889 char signature[SIGNATURE_DIGESTSIZE]; 7885 char signature[FLEXIBLE_ARRAY_MEMBER];
7890}; 7886};
7891 7887
7892static struct animation_cache *animation_cache = NULL; 7888static struct animation_cache *animation_cache = NULL;
@@ -7894,11 +7890,13 @@ static struct animation_cache *animation_cache = NULL;
7894static struct animation_cache * 7890static struct animation_cache *
7895imagemagick_create_cache (char *signature) 7891imagemagick_create_cache (char *signature)
7896{ 7892{
7897 struct animation_cache *cache = xmalloc (sizeof *cache); 7893 struct animation_cache *cache
7894 = xmalloc (offsetof (struct animation_cache, signature)
7895 + strlen (signature) + 1);
7898 cache->wand = 0; 7896 cache->wand = 0;
7899 cache->index = 0; 7897 cache->index = 0;
7900 cache->next = 0; 7898 cache->next = 0;
7901 memcpy (cache->signature, signature, SIGNATURE_DIGESTSIZE); 7899 strcpy (cache->signature, signature);
7902 return cache; 7900 return cache;
7903} 7901}
7904 7902
@@ -7932,7 +7930,6 @@ imagemagick_get_animation_cache (MagickWand *wand)
7932 struct animation_cache *cache; 7930 struct animation_cache *cache;
7933 struct animation_cache **pcache = &animation_cache; 7931 struct animation_cache **pcache = &animation_cache;
7934 7932
7935 eassert (strlen (signature) == SIGNATURE_DIGESTSIZE);
7936 imagemagick_prune_animation_cache (); 7933 imagemagick_prune_animation_cache ();
7937 7934
7938 while (1) 7935 while (1)
@@ -7943,7 +7940,7 @@ imagemagick_get_animation_cache (MagickWand *wand)
7943 *pcache = cache = imagemagick_create_cache (signature); 7940 *pcache = cache = imagemagick_create_cache (signature);
7944 break; 7941 break;
7945 } 7942 }
7946 if (memcmp (signature, cache->signature, SIGNATURE_DIGESTSIZE) == 0) 7943 if (strcmp (signature, cache->signature) == 0)
7947 break; 7944 break;
7948 pcache = &cache->next; 7945 pcache = &cache->next;
7949 } 7946 }