shuerhaaken avatar shuerhaaken committed 757b079

More image api changes for C++

Comments (0)

Files changed (27)

bindings/c/taginfo_c.cc

 //****************/TAG READ/WRITE API****************************************************
 
 
+
+
+Image ** image_list_to_image_array(const ImageList &images, int &image_count) {
+    image_count = 0;
+    if(0 < images.size()) {
+        Image ** image_array = new Image*[images.size()];
+        int i = 0;
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            image_array[i] = *it;
+            image_count++;
+        }
+        return image_array;
+    }
+    return NULL;
+}
+
 //*****************IMAGES****************************************************************
 //! Get an array of images copied from the file embedded images.
 /*!
 TagInfo_Image ** taginfo_info_get_images(const TagInfo_Info *info,
                              int *image_count) {
     const Info *i = reinterpret_cast<const Info *>(info);
-    TagInfo_Image ** images = NULL;
-    images = reinterpret_cast<TagInfo_Image **> (i->get_images((*image_count)));
+    ImageList image_list = i->get_images();
+    image_list.setAutoDelete(false);
+    TagInfo_Image ** images = reinterpret_cast<TagInfo_Image **> (image_list_to_image_array(image_list, *image_count));
     return images;
 }
+
+
+ImageList image_array_to_image_list(Image ** image_array, int image_count) {
+    ImageList list;
+    list.setAutoDelete(false);
+    for(int i = 0; i < image_count; i++) {
+        list.append(reinterpret_cast<Image *>(image_array[i]));
+    }
+    return list;
+}
+
 //! Set an array of TagInfo_Image to be embedded into the media file.
 /*!
 \param info A TagInfo_Info object
 \param image_count The length of the TagInfo_Image array
 */
 void taginfo_info_set_images(TagInfo_Info *info,
-                             const TagInfo_Image ** images, const int image_count) {
+                             TagInfo_Image ** images, const int image_count) {
     Info *i = reinterpret_cast<Info *>(info);
-    const Image ** imgs = reinterpret_cast<const Image **>(images);
-    i->set_images(imgs, image_count);
+    const ImageList img_list = image_array_to_image_list(reinterpret_cast<Image **>(images), image_count);
+    i->set_images(img_list);
 }
 
 

bindings/c/taginfo_c.h

 TagInfo_Image **        taginfo_info_get_images(const TagInfo_Info *info,
                                                 int *image_count);
 void                    taginfo_info_set_images(TagInfo_Info *info,
-                                                const TagInfo_Image ** images,
+                                                TagInfo_Image ** images,
                                                 const int image_count);
 /*----------------------------------------------------------------------------------------*/
 

libtaginfo/apetaginfo.cc

     return Info::save();
 }
 
-Image ** ApeTagInfo::get_images(int &image_count) const {
+ImageList ApeTagInfo::get_images() const {
+    ImageList images;
     if(taglib_apetag && !taglib_apetag->isEmpty()) {
-        image_count = 0;
-        Image** images;
-        List<Image*> imageList;
         if(taglib_apetag) {
             Image * image = NULL;
-            int i = 0;
             APE::ItemListMap map = taglib_apetag->itemListMap();
             for(APE::ItemListMap::ConstIterator it = map.begin(); it != map.end(); ++it) {
                 if(it->first == APE_TAG_COVER_ART_OTHER          ||
                    it->first == APE_TAG_COVER_ART_PUBLISHER_LOGO   ) {
                     image = new Image();
                     extract_image(it->second, image);
-//                    if(image->data && image->data_length > 0) {
+                    if(!image->get_data().isEmpty()) {
                         String apetype = String(it->first);
                         image->set_image_type(ape_image_type_to_image_type(apetype));
-                        imageList.prepend(image);
-                        i++;
-//                    }
-//                    else {
-//                        delete image;
-//                    }
+                        images.prepend(image);
+                    }
+                    else {
+                        delete image;
+                    }
                }
             }
-            if(0 < imageList.size()) {
-                images = new Image*[imageList.size()];
-                int ii = 0;
-                for(List<Image *>::Iterator it = imageList.begin(); it != imageList.end(); ++it) {
-                    images[ii] = (*it);
-                    ii++;
-                }
-                image_count = imageList.size();
-                return images;
-            }
         }
         
     }
-    return NULL;
+    return images;
 }
 
-void ApeTagInfo::set_images(const Image ** images, const int image_count) {
+void ApeTagInfo::set_images(const ImageList images) {
     if(taglib_apetag) {
         taglib_apetag->removeItem(APE_TAG_COVER_ART_OTHER);
         taglib_apetag->removeItem(APE_TAG_COVER_ART_ICON);
         taglib_apetag->removeItem(APE_TAG_COVER_ART_BAND_LOGO);
         taglib_apetag->removeItem(APE_TAG_COVER_ART_PUBLISHER_LOGO);
         
-        for(int p = 0; p < image_count; p++) {
-            if(images[p]->get_data().isEmpty())
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            if((*it)->get_data().isEmpty())
                 continue;
-            ByteVector image_vect(images[p]->get_data());
-//            memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
+            ByteVector image_vect((*it)->get_data());
             
             APE::Item imageItem = APE::Item();
             imageItem.setType(APE::Item::Binary);
-            String key = image_type_to_ape_image_name(images[p]->get_image_type());
+            String key = image_type_to_ape_image_name((*it)->get_image_type());
             imageItem.setKey(key);
             imageItem.setBinaryData(image_vect);
             taglib_apetag->setItem(key, imageItem);

libtaginfo/asfinfo.cc

 
 
 
-Image ** AsfInfo::get_images(int &image_count) const {
-    image_count = 0;
+ImageList AsfInfo::get_images() const {
+    ImageList images;
     if(asf_tag) {
-        Image** images;
         if(asf_tag->attributeListMap().contains(PICTURE_FLAG)) {
             ASF::AttributeList list = asf_tag->attributeListMap()[ PICTURE_FLAG ];
             if(0 >= list.size())
-                return NULL;
-            int i = list.size() - 1;
-            images = new Image*[list.size()];
+                return images;
             ASF::AttributeList::ConstIterator it = list.end();
             for(ASF::AttributeList::ConstIterator it = list.begin(); it != list.end() ; it++) {
                 ASF::Picture pict = (*it).toPicture();
                         
                         image->set_image_type(get_image_type_from_pic_type(pict.type())); 
                         image->set_description(pict.description());
-                        images[i] = image;
-                        i--;
+                        images.prepend(image);
                     }
                 }
             } 
-            image_count = list.size();
-            return images;
         }
     }
-    return NULL;
+    return images;
 }
 
-void AsfInfo::set_images(const Image ** images, const int image_count) {
+void AsfInfo::set_images(const ImageList images) {
     if(asf_tag) {
         if(asf_tag->attributeListMap().contains(PICTURE_FLAG))
             asf_tag->removeItem(PICTURE_FLAG);
         
         
-        for(int p = 0; p < image_count; p++) {
-            const Image * image = images[p];
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+//        for(int p = 0; p < image_count; p++) {
+            //images[p];
+            const Image * image = (*it);
             if( image->get_data().isEmpty())
                 continue;
             ASF::Picture picture = ASF::Picture();

libtaginfo/flacinfo.cc

     }
 }
 
-Image ** FlacInfo::get_images(int &image_count) const {
+ImageList FlacInfo::get_images() const {
+    ImageList images;
     if(flac_file) {
         List<FLAC::Picture *> plist = flac_file->pictureList();
         if(plist.size() > 0) {
-            Image** images = new Image*[plist.size()];
             for(List<FLAC::Picture *>::Iterator it = plist.begin(); it != plist.end(); ++it) {
                 Image * image = new Image();
                 FLAC::Picture * p = (*it);
                 image->set_image_type(flac_image_type_to_image_type(p->type()));
                 image->set_description(p->description());
-//                image->description = ::strdup(p->description().toCString(false));
-                image->set_data(p->data());
-//                image->data_length = p->data().size();
-//                image->data = new char[image->data_length];
-//                memcpy(image->data, p->data().data(), image->data_length);
-//                if(image->data) {
-                    images[image_count] = image;
-                    image_count++;
-//                }
-//                else {
-//                    delete image;
-//                }
+                if(!p->data().isEmpty()) {
+                    image->set_data(p->data());
+                    images.append(image);
+                }
+                else {
+                    delete image;
+                }
             }
-            return images;
         }
     }
-    return NULL;
+    return images;
 }
 
 
-void FlacInfo::set_images(const Image ** images, const int image_count) {
+void FlacInfo::set_images(const ImageList images) {
     if(flac_file) {
         flac_file->removePictures();
         
-        for(int p = 0; p < image_count; p++) {
-            if(images[p]->get_data().isEmpty())
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            if((*it)->get_data().isEmpty())
                 continue;
-//            if(!images[p]->data || images[p]->data_length == 0)
-//                continue;
-            ByteVector vect(images[p]->get_data());//((uint) images[p]->data_length);
-//            memcpy(vect.data(), images[p]->data, images[p]->data_length);
+            ByteVector vect((*it)->get_data());
             FLAC::Picture * picture = new FLAC::Picture();
             if(!picture) {
                 std::cout << "could not create picture" << std::endl;
                 continue;
             }
             picture->setData(vect);
-//            if(images[p]->description) {
-//                String desc(images[p]->description);
-                picture->setDescription(images[p]->get_description());
-//            }
+            picture->setDescription((*it)->get_description());
             picture->setMimeType("image/jpeg"); //TODO
-            picture->setType((FLAC::Picture::Type) images[p]->get_image_type());
-            //std::cout << "pic size:" << picture->data().size() << std::endl;
+            picture->setType((FLAC::Picture::Type) (*it)->get_image_type());
             flac_file->addPicture(picture);
         }
     }

libtaginfo/id3info.cc

     }
 }
 
-Image ** Id3Info::get_images(int &image_count) const {
+ImageList Id3Info::get_images() const {
+    ImageList images;
     if(taglib_tagId3v2) {
-        Image** images;
         ID3v2::FrameList framelist = taglib_tagId3v2->frameListMap()[IMAGES];
         ID3v2::AttachedPictureFrame * pic_frame = NULL;
         int cnt = framelist.size();
-        images = new Image*[cnt];
-        int i = 0;
         for(list<ID3v2::Frame*>::iterator iter = framelist.begin(); iter != framelist.end(); iter++) {
             pic_frame = static_cast<ID3v2::AttachedPictureFrame *>(*iter);
             Image * image = new Image();
                     image->set_image_file_type(IMAGE_FILE_TYPE_BMP);
                 image->set_description(pic_frame->description());
             }
-            images[i] = image;
-            i++;
+            images.append(image);
         }
-        image_count = i;
-        return images;
     }
-    return NULL;
+    return images;
 }
 
-void Id3Info::set_images(const Image ** images, const int image_count) {
+void Id3Info::set_images(const ImageList images) {
     if(taglib_tagId3v2) {
         ID3v2::AttachedPictureFrame * PicFrame = NULL;
         ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()[IMAGES];
-        for(int p = 0; p < image_count; p++) {
-            if(images[p]->get_data().isEmpty())
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            if((*it)->get_data().isEmpty())
                 continue;
             
             for(list<ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
                 PicFrame = static_cast<ID3v2::AttachedPictureFrame *>(*iter);
-                if((PicFrame->type() == image_type_to_picframetype(images[p]->get_image_type())))
+                if((PicFrame->type() == image_type_to_picframetype((*it)->get_image_type())))
                     taglib_tagId3v2->removeFrame(PicFrame, true);
             }
             PicFrame = new ID3v2::AttachedPictureFrame;
-            if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_JPEG || 
-               images[p]->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
+            if((*it)->get_image_file_type() == IMAGE_FILE_TYPE_JPEG || 
+               (*it)->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
                 PicFrame->setMimeType("image/jpeg");
-            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_PNG)
+            else if((*it)->get_image_file_type() == IMAGE_FILE_TYPE_PNG)
                 PicFrame->setMimeType("image/png");
-            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_GIF)
+            else if((*it)->get_image_file_type() == IMAGE_FILE_TYPE_GIF)
                 PicFrame->setMimeType("image/gif");
-            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_BMP)
+            else if((*it)->get_image_file_type() == IMAGE_FILE_TYPE_BMP)
                 PicFrame->setMimeType("image/bmp");
-            PicFrame->setType(image_type_to_picframetype(images[p]->get_image_type()));
-            if(!images[p]->get_description().isEmpty())
-                PicFrame->setDescription(images[p]->get_description());
-            ByteVector img_vect(images[p]->get_data());//((uint) images[p]->data_length);
+            PicFrame->setType(image_type_to_picframetype((*it)->get_image_type()));
+            if(!(*it)->get_description().isEmpty())
+                PicFrame->setDescription((*it)->get_description());
+            ByteVector img_vect((*it)->get_data());
             PicFrame->setPicture(img_vect);
             taglib_tagId3v2->addFrame(PicFrame);
         }

libtaginfo/info.cc

 //! The ownership of the images is on the caller side. You have
 //! to destroy all the images in the retured array 
 //! \return Array of Image
-Image ** Info::get_images(int &image_count) const {
-    return NULL;
+ImageList Info::get_images() const {
+    return ImageList();
 }
 //! Set an array of Image to the Info object.
 //! The ownership of the images remains on the caller side.
-//! \param images is an array of Image. Will overwrite any other Image in the
+//! \param images is an ImageList. Will overwrite any other Image in the
 //! Info object 
-//! \param image_count shall be the lenght of the image array.
-void Info::set_images(const Image ** images, const int image_count) {
+void Info::set_images(const ImageList images) {
 }
 
 //! Get an embedded Lyrics String from the Info object.

libtaginfo/mp4info.cc

 }
 
 
-Image ** Mp4Info::get_images(int &image_count) const {
-    image_count = 0;
+ImageList Mp4Info::get_images() const {
+    ImageList images;
     if(mp4_tag) {
-        Image** images;
         if(mp4_tag && mp4_tag->itemListMap().contains(COVER_IMAGES)) {
             MP4::CoverArtList covers = mp4_tag->itemListMap()[ COVER_IMAGES ].toCoverArtList();
             int cnt = covers.size();
-            images = new Image*[cnt];
             Image * image = NULL;
-            int i = 0;
             for(MP4::CoverArtList::Iterator it = covers.begin(); it != covers.end(); it++) {
                 image = new Image();
                 image->set_image_type(IMAGE_TYPE_OTHER);
                 image->set_data(it->data());
                 image->set_image_file_type(get_image_file_type_from_format(it->format()));
-                images[i] = image;
-                i++;
+                if(!it->data().isEmpty())
+                    images.append(image);
+                else
+                    delete image;
             }
-            image_count = i;
         }
-        return images;
     }
-    return NULL;
+    return images;
 }
 
 
-void Mp4Info::set_images(const Image ** images, const int image_count) {
+void Mp4Info::set_images(const ImageList images) {
     if(mp4_tag) {
         if(mp4_tag->itemListMap().contains(COVER_IMAGES)) {
             mp4_tag->itemListMap().erase(COVER_IMAGES);
         }
         MP4::CoverArtList cover_list;
-        for(int p = 0; p < image_count; p++) {
-            const Image * image = images[p];
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            const Image * image = *it;
             if(!image->get_data().isEmpty()) {
                 ByteVector image_data = image->get_data();
                 MP4::CoverArt::Format format = get_format_from_image_file_type(image->get_image_file_type());

libtaginfo/taginfo.h

   */
 namespace TagInfo {
     
+    //! TagLib::List<TagInfo::Image *> .
+    //! ImageList holds pointers to Images. Automatic memory management can be enabled
+    //! with the setAutoDelete(bool auto_delete) function.
     typedef TagLib::List<Image *> ImageList;
     
     //! \enum MediaFileType describes the media file type
             virtual bool save(void);
             
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
 
-            virtual String   get_lyrics(void) const;
-            virtual void     set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
             
             // CREATION METHODS
             static Info * create(const String &filename);

libtaginfo/taginfo_apetags.h

             virtual bool load(void);
             virtual bool save(void);
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
             
-            virtual String   get_lyrics(void) const;
-            virtual void     set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
     };
     
     

libtaginfo/taginfo_asftags.h

             virtual bool load(void);
             virtual bool save(void);
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
             
-            virtual String   get_lyrics(void) const;
-            virtual void     set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
     };
 }
 

libtaginfo/taginfo_id3tags.h

             virtual bool load(void);
             virtual bool save();
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
             
-            virtual String   get_lyrics(void) const;
-            virtual void     set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
     };
     
     

libtaginfo/taginfo_mp4tags.h

             virtual bool load(void);
             virtual bool save(void);
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
             
-            virtual String   get_lyrics(void) const;
-            virtual void     set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
     };
 }
 

libtaginfo/taginfo_xiphtags.h

             virtual bool load(void);
             virtual bool save(void);
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
             
-            virtual String get_lyrics(void) const;
-            virtual void   set_lyrics(const String &lyrics);
+            virtual String    get_lyrics(void) const;
+            virtual void      set_lyrics(const String &lyrics);
     };
     
     // FILE TYPES
             
             virtual bool load(void);
             
-            virtual Image ** get_images(int &image_count) const;
-            virtual void     set_images(const Image ** images, const int image_count);
+            virtual ImageList get_images() const;
+            virtual void      set_images(const ImageList images);
     };
     
     

libtaginfo/xiphinfo.cc

 }
 
 
-Image ** XiphInfo::get_images(int &image_count) const {
-    image_count = 0;
+ImageList XiphInfo::get_images() const {
+    ImageList images;
     if(xiphcomment && xiphcomment->contains(COVERART)) {
         
         StringList pics      = xiphcomment->fieldListMap()[ COVERART ];
         int mimes_cnt = pic_mimes.size();
         int types_cnt = pic_types.size();
         int descr_cnt = pic_descr.size();
-        Image** images = new Image*[cnt];
         for(int i = 0; i < cnt; i++) {
             Image * image = new Image();
             String mimetype;
             
             ByteVector bv(CoverDecData.data(), CoverDecData.size());
             image->set_data(bv);
-            images[i] = image;
-            image_count++;
+            images.append(image);
         }
-        return images;
     }
-    return NULL;
+    return images;
 }
 
-void XiphInfo::set_images(const Image ** images, const int image_count) {
+void XiphInfo::set_images(const ImageList images) {
     if(xiphcomment) {
         xiphcomment->removeField(COVERARTMIME);
         xiphcomment->removeField(COVERART);
         xiphcomment->removeField(COVERARTTYPE);
         xiphcomment->removeField(COVERARTDESCRIPTION);
-         for(int p = 0; p < image_count; p++) {
-            const Image * image = images[p];
+        for(ImageList::ConstIterator it = images.begin(); it != images.end(); ++it) {
+            const Image * image = *it;
             if(!image->get_data().isEmpty()) {
                 if(image->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN || 
                    image->get_image_file_type() == IMAGE_FILE_TYPE_JPEG)

tests/ctest_write/main.c

 #include <errno.h>
 #include <sys/mman.h>
 
-#define TESTTITLE "test title äöüß"
+#define TESTTITLE       "test title äöüß"
+#define DESCRIPTION     "Däß krip tiön"
 
 int cp(const char *from, const char *to) {
     int fd_to, fd_from;
     char val[200] = TESTDIR "samples/sample.flac";
     const char* target = "/tmp/out_c03.flac";
     const char* s = val;
-    const char* image = TESTDIR "samples/test.jpg";
+    const char* image_path = TESTDIR "samples/test.jpg";
     
     //printf("##1\n");
-    
     if(cp(s, target) < 0)
         return 1; //EXIT_FAILURE
     
     info = taginfo_info_create(target);
     
-    printf("**1: \n");
     if(info == NULL)
         return 1; //EXIT_FAILURE
     struct stat filestatus;
     int fd;
-    stat( image, &filestatus );
-/*    printf("filestatus.st_size: %d\n", (int)filestatus.st_size);*/
-
+    stat( image_path, &filestatus );
+    /*printf("filestatus.st_size: %d\n", (int)filestatus.st_size);*/
     
-    fd = open(image, O_RDONLY);
+    fd = open(image_path, O_RDONLY);
     if (fd == -1) {
         perror("Error opening file for reading");
         return 1;
     TagInfo_Image * img = taginfo_image_new();
     taginfo_image_set_data(img, (char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (unsigned int)filestatus.st_size);
     taginfo_image_set_image_type(img, TAG_INFO_IMAGE_TYPE_OTHER);
-/*    unsigned int gg = 0;*/
-/*    char * ch = taginfo_image_get_data(img, &gg);*/
-/*    return 0;*/
-/*    printf("%s", ch);*/
+    taginfo_image_set_description(img, strdup(DESCRIPTION));
     TagInfo_Image ** ima = malloc(1 * sizeof(img));
     *ima = img;
     
-    taginfo_info_set_images(info, (const TagInfo_Image **)ima, 1);
+    taginfo_info_set_images(info, ima, 1);
     
     taginfo_info_set_album(info, TESTTITLE " älbum");
     taginfo_info_set_albumartist(info, TESTTITLE "äé");
     taginfo_info_set_track_labels(info,  (const char * const*)labels, labels_length);
     taginfo_info_save(info);
     taginfo_info_free(info);
-/*    return 0;*/
     info = taginfo_info_create(target);
     int bla = 0;
-    TagInfo_Image ** iout = taginfo_info_get_images(info, &bla);
+    
     int j = 0;
     if(taginfo_info_load(info)) {
+        printf("++1\n");
+        TagInfo_Image ** iout = taginfo_info_get_images(info, &bla);
+        printf("++2 %d\n", bla);
+        int i;
+        if(bla <= 0)
+            return 1;
+        TagInfo_Image * image = iout[0];
+        if(!image)
+            return 1;
+        if(strcmp(taginfo_image_get_description(image), DESCRIPTION) != 0)
+            return 1; //EXIT_FAILURE
+        unsigned int len = 0;
+        unsigned int org_len = 0;
+        char * idat   = taginfo_image_get_data(image, &len);
+        char * orgdat = taginfo_image_get_data(img, &org_len);
+        if(filestatus.st_size != len)
+            return 1; //EXIT_FAILURE
+        for(i = 0; i < len; i++) {
+            if(orgdat[i] != idat[i]) {
+                return 1; //EXIT_FAILURE
+            }
+        }
         int out_labels_length_artist = 0;
         char** out_labels_artist = taginfo_info_get_artist_labels(info, &out_labels_length_artist);
         int out_labels_length_album = 0;

tests/write_image_ape/main.cc

     
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
+//                    if(images)
+//                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
+//                if(images)
+//                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
+//                if(images)
+//                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
             if(img->get_data() != read_image->get_data()) {
-                if(images)
-                    delete [] images;
+//                if(images)
+//                    delete [] images;
                 return EXIT_FAILURE;
             }
             if(img2->get_data() != read_image2->get_data()) {
-                if(images)
-                    delete [] images;
+//                if(images)
+//                    delete [] images;
                 return EXIT_FAILURE;
             }
-            if(images)
-                delete [] images;
+//            if(images)
+//                delete [] images;
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_flac/main.cc

     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images;
+            images.setAutoDelete(true);
+            images = info->get_images();
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
 //            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
 //            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
 //            for(i = 0; i<img->data_length; i++) {
 //                if(img->data[i] != read_image->data[i]) {
                 if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
 //            }
 //            for(i = 0; i<img2->data_length; i++) {
 //                if(img2->data[i] != read_image2->data[i]) {
                 if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
 //            }
-            if(images)
-                delete [] images;
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_mp3/main.cc

     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
     
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_mp4/main.cc

     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
 //            if(img->get_image_type() != read_image->get_image_type()) {
-//                if(images)
-//                    delete [] images;
 //                if(read_image)
 //                    delete read_image;
 //                return EXIT_FAILURE;
 //            }
 //            String st = String(read_image->description);
 //            if(img->get_description() != read_image->get_description()) {
-//                if(images)
-//                    delete [] images;
 //                if(read_image)
 //                    delete read_image;
 //                return EXIT_FAILURE;
 //            }
 ////            st = String(read_image2->description);
 //            if(img2->get_description() != read_image2->get_description()) {
-//                if(images)
-//                    delete [] images;
 //                if(read_image)
 //                    delete read_image;
 //                return EXIT_FAILURE;
 //            }
 //            if(img2->get_image_type() != read_image2->get_image_type()) {
-//                if(images)
-//                    delete [] images;
 //                if(read_image)
 //                    delete read_image;
 //                return EXIT_FAILURE;
 //            for(i = 0; i<img->data_length; i++) {
 //                if(img->data[i] != read_image->data[i]) {
                 if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
 //            }
 //            for(i = 0; i<img2->data_length; i++) {
 //                if(img2->data[i] != read_image2->data[i]) {
                 if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
 //            }
-            if(images)
-                delete [] images;
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_mpc/main.cc

     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
-    
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
+            delete info;
             return EXIT_SUCCESS;
         }
         delete info;

tests/write_image_ogg/main.cc

 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
-    //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
     
-std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     info = NULL;
     
-std::cout <<  "++2 " << std::endl;
     info = Info::create(target);
     Image * read_image;
     Image * read_image2;
     if(info) {
-std::cout <<  "++3 " << std::endl;
         if(info->load()) {
             int len = 0;
-std::cout <<  "++4 " << std::endl;
-            Image ** images = info->get_images(len);
-std::cout <<  "++5 " << std::endl;
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
                 }
                 return EXIT_FAILURE;
             }
-std::cout <<  "++6 " << std::endl;
             read_image  = images[0];
             read_image2 = images[1];
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
-std::cout <<  "++7 " << std::endl;
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-std::cout <<  "++8 " << std::endl;
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-std::cout <<  "++8.1 : " << img->get_data().size() << " " << read_image->get_data().size() << std::endl;
-std::cout <<  "++8.2 : " << img2->get_data().size() << " " << read_image2->get_data().size() << std::endl;
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-std::cout <<  "++9 " << std::endl;
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_speex/main.cc

     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
-    
-    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_tta/main.cc

 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
-    //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
-    
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data())
+                return EXIT_FAILURE;
+            if(img2->get_data() != read_image2->get_data()) 
+                return EXIT_FAILURE;
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_wav/main.cc

     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
     
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_wma/main.cc

     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
     
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
-//            String st = String(read_image->description);
             if(img->get_description() != read_image->get_description()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
-//            st = String(read_image2->description);
             if(img2->get_description() != read_image2->get_description()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;

tests/write_image_wv/main.cc

     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
     
     img->set_data(vect);
     img2->set_data(vect2);
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
     
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
-        Image ** imgs = new Image*[2];
-        imgs[0] = img;
-        imgs[1] = img2;
-        info->set_images((const Image **)imgs, 2);
-        if(imgs)
-            delete [] imgs;
+        ImageList imgs;
+        imgs.append(img);
+        imgs.append(img2);
+        info->set_images(imgs);
         info->save();
     }
     delete info;
     if(info) {
         if(info->load()) {
             int len = 0;
-            Image ** images = info->get_images(len);
-            if(!images) {
+            ImageList images = info->get_images();
+            images.setAutoDelete(true);
+            if(images.isEmpty()) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(images)
-                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
             if(img->get_image_type() != read_image->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             if(img2->get_image_type() != read_image2->get_image_type()) {
-                if(images)
-                    delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
             int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-                if(img->get_data() != read_image->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-                if(img2->get_data() != read_image2->get_data()) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-//            }
-            if(images)
-                delete [] images;
+            if(img->get_data() != read_image->get_data()) {
+                return EXIT_FAILURE;
+            }
+            if(img2->get_data() != read_image2->get_data()) {
+                return EXIT_FAILURE;
+            }
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;
     return EXIT_FAILURE;
 }
 
-
-
-
-//#include "taginfo.h"
-//#include <stdio.h>
-//#include <iostream>
-//#include <fstream>
-//#include <sys/mman.h>
-//#include <fcntl.h>
-//#include <unistd.h>
-//#include <sys/types.h>
-//#include <sys/stat.h>
-
-//using namespace TagInfo;
-
-
-//int main( void ) {
-//    Info * info;
-//    std::string val   = TESTDIR "samples/sample.wv";
-//    std::string image = TESTDIR "samples/test.jpg";
-//    std::string target = "/tmp/out_01.wv";
-//    
-//    std::ifstream  src(val.c_str());
-//    std::ofstream  dst(target.c_str());
-//    dst << src.rdbuf();
-//    
-//    Image * img = new Image();
-//    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-//    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-//    
-//    Image * img2 = new Image();
-//    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-//    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-
-//    struct stat filestatus;
-//    stat( image.c_str(), &filestatus );
-//    //cout << filestatus.st_size << " bytes\n";
-//    img->data_length = filestatus.st_size;
-//    img2->data_length = filestatus.st_size;
-//    int fd;
-//    
-//    fd = open(image.c_str(), O_RDONLY);
-//    if (fd == -1) {
-//        perror("Error opening file for reading");
-//        EXIT_FAILURE;
-//    }
-//    
-//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-//        close(fd);
-//        perror("Error mmapping the file");
-//        EXIT_FAILURE;
-//    }
-//    
-//    info = Info::create(target);
-//    if(info) {
-//        Image ** imgs = new Image*[2];
-//        imgs[0] = img;
-//        imgs[1] = img2;
-//        info->set_images((const Image **)imgs, 2);
-//        if(imgs)
-//            delete [] imgs;
-//        info->save();
-//    }
-//    delete info;
-//    info = NULL;
-//    
-//    info = Info::create(target);
-//    Image * read_image;
-//    Image * read_image2;
-//    if(info) {
-//        if(info->load()) {
-//            int len = 0;
-//            Image ** images = info->get_images(len);
-//            if(!images) {
-//                delete info;
-//                if(remove(target.c_str()) != 0 ) {
-//                    return EXIT_FAILURE;
-//                }
-//                return EXIT_FAILURE;
-//            }
-//            read_image  = images[0];
-//            read_image2 = images[1];
-//            if(!images[0] || !read_image|| !read_image2) {
-//                delete info;
-//                if(remove(target.c_str()) != 0 ) {
-//                    if(images)
-//                        delete [] images;
-//                    return EXIT_FAILURE;
-//                }
-//            }
-//            if(img->image_type != read_image->image_type) {
-//                if(images)
-//                    delete [] images;
-//                if(read_image)
-//                    delete read_image;
-//                return EXIT_FAILURE;
-//            }
-//            if(img2->image_type != read_image2->image_type) {
-//                if(images)
-//                    delete [] images;
-//                if(read_image)
-//                    delete read_image;
-//                return EXIT_FAILURE;
-//            }
-//            int i;
-//            for(i = 0; i<img->data_length; i++) {
-//                if(img->data[i] != read_image->data[i]) {
-//                    if(images)
-//                        delete [] images;
-//                    return EXIT_FAILURE;
-//                }
-//            }
-//            for(i = 0; i<img2->data_length; i++) {
-//                if(img2->data[i] != read_image2->data[i]) {
-//                    if(images)
-//                        delete [] images;
-//                    return EXIT_FAILURE;
-//                }
-//            }
-//            if(images)
-//                delete [] images;
-//            if(remove(target.c_str()) != 0 )
-//                return EXIT_FAILURE;
-//            return EXIT_SUCCESS;
-//        }
-//        delete info;
-//        if(remove(target.c_str()) != 0 )
-//            return EXIT_FAILURE;
-//        return EXIT_FAILURE;
-//    }
-//    else {
-//       delete info;
-//        if(remove(target.c_str()) != 0 )
-//            return EXIT_FAILURE;
-//        return EXIT_FAILURE;
-//    }
-//    return EXIT_FAILURE;
-//}
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.