]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 1 Sep 2011 13:11:19 +0000 (13:11 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 1 Sep 2011 13:11:19 +0000 (13:11 +0000)
MagickCore/string.c
MagickCore/string_.h
coders/jpeg.c
coders/pict.c
coders/png.c
coders/ps.c
coders/psd.c

index 4e1504fd8988c40e954f656624382eff379c3c71..fc4dfc5a7696a34fbb14532f98bc8f0cd0371f1b 100644 (file)
@@ -182,6 +182,48 @@ MagickExport StringInfo *AcquireStringInfo(const size_t length)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   B l o b T o S t r i n g I n f o                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  BlobToStringInfo() returns the contents of a blob as a string.
+%
+%  The format of the BlobToStringInfo method is:
+%
+%      StringInfo *BlobToStringInfo(const void *blob,const size_t length)
+%
+%  A description of each parameter follows:
+%
+%    o blob: the blob.
+%
+%    o length: the length of the blob.
+%
+*/
+MagickExport StringInfo *BlobToStringInfo(const void *blob,const size_t length)
+{
+  StringInfo
+    *string_info;
+
+  string_info=AcquireStringInfo(0);
+  string_info->datum=(unsigned char *) AcquireQuantumMemory(length,
+    sizeof(*string_info->datum));
+  if (string_info->datum == (unsigned char *) NULL)
+    {
+      string_info=DestroyStringInfo(string_info);
+      return((StringInfo *) NULL);
+    }
+  if (blob != (const void *) NULL)
+    (void) memcpy(string_info->datum,blob,length);
+  return(string_info);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   C l o n e S t r i n g                                                     %
 %                                                                             %
 %                                                                             %
index 96f6c0b4c7a30ff6cf528cc039a71557734f6c10..fd91415d88d0fc2176a24542bf127218f56f2b54 100644 (file)
@@ -79,6 +79,7 @@ extern MagickExport ssize_t
 
 extern MagickExport StringInfo
   *AcquireStringInfo(const size_t),
+  *BlobToStringInfo(const void *,const size_t),
   *CloneStringInfo(const StringInfo *),
   *ConfigureFileToStringInfo(const char *),
   *DestroyStringInfo(StringInfo *),
index 69f7d1772f34adaf15faecf64a5b3e49b37144f4..68a96e4b7c4d3686e6c74a9e444727e3d509188c 100644 (file)
@@ -445,7 +445,7 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info)
   length-=14;
   error_manager=(ErrorManager *) jpeg_info->client_data;
   image=error_manager->image;
-  profile=AcquireStringInfo(length);
+  profile=BlobToStringInfo((const void *) NULL,length);
   if (profile == (StringInfo *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
@@ -541,7 +541,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
     return(MagickTrue);
   error_manager=(ErrorManager *) jpeg_info->client_data;
   image=error_manager->image;
-  profile=AcquireStringInfo(length);
+  profile=BlobToStringInfo((const void *) NULL,length);
   if (profile == (StringInfo *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
@@ -612,7 +612,7 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info)
   (void) FormatLocaleString(name,MaxTextExtent,"APP%d",marker);
   error_manager=(ErrorManager *) jpeg_info->client_data;
   image=error_manager->image;
-  profile=AcquireStringInfo(length);
+  profile=BlobToStringInfo((const void *) NULL,length);
   if (profile == (StringInfo *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
index e851b6ace3a213482e188a731be5cce64308a127..5212776f924274a5bbaa96434a19571b872ec7f9 100644 (file)
@@ -1273,7 +1273,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
               {
                 if (length == 0)
                   break;
-                profile=AcquireStringInfo(length);
+                profile=BlobToStringInfo((const void *) NULL,length);
                 SetStringInfoDatum(profile,info);
                 status=SetImageProfile(image,"icc",profile);
                 profile=DestroyStringInfo(profile);
@@ -1286,7 +1286,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
               {
                 if (length == 0)
                   break;
-                profile=AcquireStringInfo(length);
+                profile=BlobToStringInfo((const void *) NULL,length);
                 SetStringInfoDatum(profile,info);
                 status=SetImageProfile(image,"iptc",profile);
                 if (status == MagickFalse)
index 91c51944188dcc6a479bccccd4ad12dbfe059338..686fc777354d80d9b9e02af3a4738a8c1f8b71d1 100644 (file)
@@ -1849,7 +1849,7 @@ Magick_png_read_raw_profile(Image *image, const ImageInfo *image_info,
     return(MagickFalse);
   }
 
-  profile=AcquireStringInfo(length);
+  profile=BlobToStringInfo((const void *) NULL,length);
 
   if (profile == (StringInfo *) NULL)
   {
index 41e9d329e35c1ff37d10283412801c39a7a8db3a..a0d6d326f8e85752eba7c32108a8846d7199896d 100644 (file)
@@ -557,7 +557,7 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (count != 1)
           continue;
         length=extent;
-        profile=AcquireStringInfo(length);
+        profile=BlobToStringInfo((const void *) NULL,length);
         p=GetStringInfoDatum(profile);
         for (i=0; i < (ssize_t) length; i++)
           *p++=(unsigned char) ProfileInteger(image,hex_digits);
index a0ad522e595c27726e2ae783cfc42cd14a63de51..5c8ad2206ba8beec22eb46ca34d136101113b692 100644 (file)
@@ -424,7 +424,7 @@ static MagickBooleanType ParseImageResourceBlocks(Image *image,
 
   if (length < 16)
     return(MagickFalse);
-  profile=AcquireStringInfo(length);
+  profile=BlobToStringInfo((const void *) NULL,length);
   SetStringInfoDatum(profile,blocks);
   (void) SetImageProfile(image,"8bim",profile);
   profile=DestroyStringInfo(profile);