+2013-08-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * 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.
+
2013-08-19 Paul Eggert <eggert@cs.ucla.edu>
* image.c: Shrink memory needed for animation cache.
separate from the image cache, because the images may be scaled
before display. */
-/* Size of ImageMagick image signatures, in bytes. It's SHA-256 as a
- hex string, so it's 256 bits represented via 4 bits per byte. */
-enum { SIGNATURE_DIGESTSIZE = 256 / 4 };
-
struct animation_cache
{
MagickWand *wand;
int index;
EMACS_TIME update_time;
struct animation_cache *next;
- char signature[SIGNATURE_DIGESTSIZE];
+ char signature[FLEXIBLE_ARRAY_MEMBER];
};
static struct animation_cache *animation_cache = NULL;
static struct animation_cache *
imagemagick_create_cache (char *signature)
{
- struct animation_cache *cache = xmalloc (sizeof *cache);
+ struct animation_cache *cache
+ = xmalloc (offsetof (struct animation_cache, signature)
+ + strlen (signature) + 1);
cache->wand = 0;
cache->index = 0;
cache->next = 0;
- memcpy (cache->signature, signature, SIGNATURE_DIGESTSIZE);
+ strcpy (cache->signature, signature);
return cache;
}
struct animation_cache *cache;
struct animation_cache **pcache = &animation_cache;
- eassert (strlen (signature) == SIGNATURE_DIGESTSIZE);
imagemagick_prune_animation_cache ();
while (1)
*pcache = cache = imagemagick_create_cache (signature);
break;
}
- if (memcmp (signature, cache->signature, SIGNATURE_DIGESTSIZE) == 0)
+ if (strcmp (signature, cache->signature) == 0)
break;
pcache = &cache->next;
}