% %
% %
% %
++ 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 %
% %
% %
*/
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
/*