]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 20 Sep 2014 01:00:50 +0000 (01:00 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 20 Sep 2014 01:00:50 +0000 (01:00 +0000)
MagickCore/blob-private.h
MagickCore/blob.c
MagickCore/image.c

index 12b12ff3f8c149b962ec7b0552556e2b5b989b2f..6f265ab1ff8ac29471dbdcdaded1cda70cbe62c0 100644 (file)
@@ -57,6 +57,7 @@ extern MagickPrivate StreamHandler
   GetBlobStreamHandler(const Image *);
 
 extern MagickPrivate void
+  DisassociateBlob(Image *),
   GetBlobInfo(BlobInfo *),
   SetBlobExempt(Image *,const MagickBooleanType);
 
index 5c3154b1ba09e0937635ff275255078cd284cbde..2d51b61b89e2bf56ea5a9b6fe83ea2fa6dba7f76 100644 (file)
@@ -713,6 +713,57 @@ MagickExport unsigned char *DetachBlob(BlobInfo *blob_info)
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   D i s a s s o c i a t e B l o b                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DisassociateBlob() disassociates the image stream.  It checks if the
+%  blob of the specified image is referenced by other images. If the reference
+%  count is higher then 1 a new blob is assigned to the specified image.
+%
+%  The format of the DisassociateBlob method is:
+%
+%      MagickBooleanType DisassociateBlob(const Image *image)
+%
+%  A description of each parameter follows:
+%
+%    o image: the image.
+%
+*/
+MagickPrivate void DisassociateBlob(Image *image)
+{
+  BlobInfo
+    *blob;
+
+  MagickBooleanType
+    clone;
+
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  if (image->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  assert(image->blob != (BlobInfo *) NULL);
+  assert(image->blob->signature == MagickSignature);
+  clone=MagickFalse;
+  LockSemaphoreInfo(image->blob->semaphore);
+  assert(image->blob->reference_count >= 0);
+  if (image->blob->reference_count > 1)
+    clone=MagickTrue;
+  UnlockSemaphoreInfo(image->blob->semaphore);
+  if (clone == MagickFalse)
+    return;
+  blob=CloneBlobInfo(image->blob);
+  DestroyBlob(image);
+  image->blob=blob;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 +  D i s c a r d B l o b B y t e s                                            %
 %                                                                             %
 %                                                                             %
index 2cfc6ed41ce1686f4ce230686d270efb0470b66c..ea8282510f5c2f1aead39e3eab8f42334ac0dd1c 100644 (file)
@@ -1150,29 +1150,11 @@ MagickExport ImageInfo *DestroyImageInfo(ImageInfo *image_info)
 */
 MagickExport void DisassociateImageStream(Image *image)
 {
-  BlobInfo
-    *blob;
-
-  MagickBooleanType
-    clone;
-
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  assert(image->blob != (BlobInfo *) NULL);
-  assert(image->blob->signature == MagickSignature);
-  clone=MagickFalse;
-  LockSemaphoreInfo(image->blob->semaphore);
-  assert(image->blob->reference_count >= 0);
-  if (image->blob->reference_count > 1)
-    clone=MagickTrue;
-  UnlockSemaphoreInfo(image->blob->semaphore);
-  if (clone == MagickFalse)
-    return;
-  blob=CloneBlobInfo(image->blob);
-  DestroyBlob(image);
-  image->blob=blob;
+  DisassociateBlob(image);
 }
 \f
 /*