emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113954: * image.c (SIGNATURE_DIGESTSIZE): Remove.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113954: * image.c (SIGNATURE_DIGESTSIZE): Remove.
Date: Tue, 20 Aug 2013 00:51:44 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113954
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2013-08-19 17:51:35 -0700
message:
  * 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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/image.c                    image.c-20091113204419-o5vbwnq5f7feedwu-2969
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-19 20:47:27 +0000
+++ b/src/ChangeLog     2013-08-20 00:51:35 +0000
@@ -1,3 +1,10 @@
+2013-08-20  Paul Eggert  <address@hidden>
+
+       * 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  <address@hidden>
 
        * image.c: Shrink memory needed for animation cache.

=== modified file 'src/image.c'
--- a/src/image.c       2013-08-19 20:47:27 +0000
+++ b/src/image.c       2013-08-20 00:51:35 +0000
@@ -7876,17 +7876,13 @@
    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;
@@ -7894,11 +7890,13 @@
 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;
 }
 
@@ -7932,7 +7930,6 @@
   struct animation_cache *cache;
   struct animation_cache **pcache = &animation_cache;
 
-  eassert (strlen (signature) == SIGNATURE_DIGESTSIZE);
   imagemagick_prune_animation_cache ();
 
   while (1)
@@ -7943,7 +7940,7 @@
           *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;
     }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]