]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/artifact.c
(no commit message)
[imagemagick] / MagickCore / artifact.c
index e42b73faebbc083a229bc88d7392636c267b03de..b51c7114702ed3403e0ddedfe57f8471dc839b33 100644 (file)
 %                         MagickCore Artifact Methods                         %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 March 2000                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -112,8 +112,12 @@ MagickExport MagickBooleanType CloneImageArtifacts(Image *image,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       clone_image->filename);
   if (clone_image->artifacts != (void *) NULL)
-    image->artifacts=CloneSplayTree((SplayTreeInfo *) clone_image->artifacts,
-      (void *(*)(void *)) ConstantString,(void *(*)(void *)) ConstantString);
+    {
+      if (image->artifacts != (void *) NULL)
+        DestroyImageArtifacts(image);
+      image->artifacts=CloneSplayTree((SplayTreeInfo *) clone_image->artifacts,
+        (void *(*)(void *)) ConstantString,(void *(*)(void *)) ConstantString);
+    }
   return(MagickTrue);
 }
 \f
@@ -197,8 +201,7 @@ MagickExport MagickBooleanType DeleteImageArtifact(Image *image,
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->artifacts == (void *) NULL)
     return(MagickFalse);
   return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->artifacts,artifact));
@@ -232,8 +235,7 @@ MagickExport void DestroyImageArtifacts(Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->artifacts != (void *) NULL)
     image->artifacts=(void *) DestroySplayTree((SplayTreeInfo *)
       image->artifacts);
@@ -288,22 +290,15 @@ MagickExport const char *GetImageArtifact(const Image *image,
     }
   if (image->artifacts != (void *) NULL)
     {
-      p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
-        image->artifacts,artifact);
+      p=(const char *) GetValueFromSplayTree((SplayTreeInfo *) image->artifacts,
+        artifact);
       if (p != (const char *) NULL)
         return(p);
     }
-  /* Programmer notes....
-     CLI IMv7: if no per-image artifact - look for a global option instead
-     CLI IMv6: global options are copied into per-image artifacts
-     In all other cases, if image is not part of an image_info image list this
-     pointer should be NULL, an no global image options are available.
-   */
-
-  if ( (image->image_info != (ImageInfo *)NULL) &&
-       (image->image_info->options != (void *) NULL) )
+  if ((image->image_info != (ImageInfo *) NULL) &&
+      (image->image_info->options != (void *) NULL))
     p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
-        image->image_info->options,artifact);
+      image->image_info->options,artifact);
   return(p);
 }
 \f
@@ -334,8 +329,7 @@ MagickExport char *GetNextImageArtifact(const Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->artifacts == (void *) NULL)
     return((char *) NULL);
   return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->artifacts));
@@ -377,8 +371,7 @@ MagickExport char *RemoveImageArtifact(Image *image,const char *artifact)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->artifacts == (void *) NULL)
     return((char *) NULL);
   value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->artifacts,
@@ -418,8 +411,7 @@ MagickExport void ResetImageArtifactIterator(const Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->artifacts == (void *) NULL)
     return;
   ResetSplayTreeIterator((SplayTreeInfo *) image->artifacts);
@@ -436,7 +428,7 @@ MagickExport void ResetImageArtifactIterator(const Image *image)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  SetImageArtifact() associates makes a copy of the given string value
+%  SetImageArtifact() associates makes a copy of the given string arguments
 %  and inserts it into the artifact tree of the given image.
 %
 %  The format of the SetImageArtifact method is:
@@ -448,9 +440,9 @@ MagickExport void ResetImageArtifactIterator(const Image *image)
 %
 %    o image: the image.
 %
-%    o artifact: the image artifact.
+%    o artifact: the image artifact key.
 %
-%    o values: the image artifact values.
+%    o value: the image artifact value.
 %
 */
 MagickExport MagickBooleanType SetImageArtifact(Image *image,
@@ -462,19 +454,21 @@ MagickExport MagickBooleanType SetImageArtifact(Image *image,
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      image->filename);
-
-  /* Create tree if needed - specify how key,values are to be freed */
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  /*
+    Create tree if needed - specify how key,values are to be freed.
+  */
   if (image->artifacts == (void *) NULL)
-    image->artifacts=NewSplayTree(CompareSplayTreeString,
-      RelinquishMagickMemory,RelinquishMagickMemory);
-
-  /* Delete artifact if NULL --  empty string values are valid! */
+    image->artifacts=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
+      RelinquishMagickMemory);
+  /*
+    Delete artifact if NULL --  empty string values are valid!,
+  */
   if (value == (const char *) NULL)
     return(DeleteImageArtifact(image,artifact));
-
-  /* add artifact to splay-tree */
+  /*
+    Add artifact to splay-tree.
+  */
   status=AddValueToSplayTree((SplayTreeInfo *) image->artifacts,
     ConstantString(artifact),ConstantString(value));
   return(status);