[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: [MD:7566] ImageMagick の動作確認



藤井です。

From: Eisaku YAMAGUCHI <eisaku@xxxxxxxxxxxxxxxxxx>
Subject: Re: [MD:7566] ImageMagick の動作確認
Date: Thu, 04 Sep 2008 12:26:33 +0900 (JST)
> Meadow-develop ML を今一度洗い直さないといけませんでした.
> Meadow 3.00-dev ではなくて,SVN では今春に 3.01-dev になっているの
> ですね.
> やはり,SVN からの rebuild 環境を試さねばいけませんね.;-)

ImageMagick のバージョンが上る度にちゃんと起動できるかどうか(つまり、
NSTATICS の値が十分かどうか)を検証するのはメンテナンス上良くないと思い
ます。

現在のように ImageMagick がサポートする画像フォーマットのうち、
staticpro() されてなさそうなものは全て個別に staticpro() すると、
staticpro() の回数が動的に決定するので、常に上限を超えるリスクが伴いま
す。

そこで、一つのリストに ImageMagick がサポートする画像のシンボルを格納し、
その一つのリストを statipro() するように変更した方が良いと思います。

このリストを elisp では操作できないところに置いておけば、いつの間にか
プロテクトの対象から外れることはないと思います。

貼り付けたパッチのようにすれば、Meadow 向けに NSTATICS の数を水増し
しなくても動作するようになります。

--
藤井 正行 / Masayuki FUJII


Index: src/image.c
===================================================================
--- src/image.c	(revision 4240)
+++ src/image.c	(working copy)
@@ -9269,6 +9269,9 @@
 
 extern Lisp_Object Qxbm, Qpbm, Qxpm, Qjpeg, Qtiff, Qgif, Qpng;
 
+/* A list of symbols, one for each image type supported by ImageMagick.  */
+Lisp_Object imagemagick_image_types;
+
 static int imagemagick_get_bits_per_pixel (MagickWand *);
 
 /* ImageMagick function pointers.  */
@@ -10485,13 +10488,17 @@
     {
       struct image_type *type = lookup_image_type (sym);
       if (type)
-	return type->type;
+	{
+	  imagemagick_image_types = Fcons (*type->type,
+					   imagemagick_image_types);
+	  return type->type;
+	}
     }
 
   /* This image type seems not match prescribed type.  */
   psym = (Lisp_Object *) xmalloc (sizeof (Lisp_Object));
   *psym = Fintern (lowerstr, Qnil);
-  staticpro (psym);
+  imagemagick_image_types = Fcons (*psym, imagemagick_image_types);
 
   return psym;
 }
@@ -10509,6 +10516,9 @@
   img_type.free = mw32_destruct_image;
   img_type.next = NULL;
 
+  imagemagick_image_types = Qnil;
+  staticpro (&imagemagick_image_types);
+
   if (formats == NULL)
     return 0;
 
Index: src/alloc.c
===================================================================
--- src/alloc.c	(revision 4240)
+++ src/alloc.c	(working copy)
@@ -503,11 +503,7 @@
 /* Addresses of staticpro'd variables.  Initialize it to a nonzero
    value; otherwise some compilers put it into BSS.  */
 
-#ifdef MEADOW
-#define NSTATICS 1540
-#else
 #define NSTATICS 1280
-#endif
 Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
 
 /* Index of next unused slot in staticvec.  */