extern MagickPrivate void
GetBlobInfo(BlobInfo *),
- GetBlobPrivate(Image *),
SetBlobExempt(Image *,const MagickBooleanType);
#if defined(__cplusplus) || defined(c_plusplus)
blob_info->semaphore=AcquireSemaphoreInfo();
blob_info->signature=MagickSignature;
}
-
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-+ G e t B l o b P r i v a t e %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% GetBlobPrivate() 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 GetBlobError method is:
-%
-% void GetBlobPrivate(Image *image)
-%
-% A description of each parameter follows:
-%
-% o image: the image.
-%
-*/
-MagickPrivate void GetBlobPrivate(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
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
assert(exception != (ExceptionInfo *) NULL);
sans_exception=AcquireExceptionInfo();
write_info=CloneImageInfo(image_info);
- GetBlobPrivate(image);
(void) CopyMagickString(write_info->filename,image->filename,MaxTextExtent);
if (*write_info->magick == '\0')
(void) CopyMagickString(write_info->magick,image->magick,MaxTextExtent);
assert(exception != (ExceptionInfo *) NULL);
write_info=CloneImageInfo(image_info);
images=GetFirstImageInList(images);
- GetBlobPrivate(images);
if (filename != (const char *) NULL)
for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
(void) CopyMagickString(p->filename,filename,MaxTextExtent);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% DisassociateImageStream() disassociates the image stream.
+% DisassociateImageStream() 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 DisassociateImageStream method is:
%
*/
MagickExport void DisassociateImageStream(Image *image)
{
- unsigned char
- *data;
+ BlobInfo
+ *blob;
- assert(image != (const Image *) NULL);
+ MagickBooleanType
+ clone;
+
+ assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- data=DetachBlob(image->blob);
- if (data != (unsigned char *) NULL)
- data=(unsigned char *) RelinquishMagickMemory(data);
+ 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
/*