Hi Sahon,

I couldn't reproduce the error.  One suggestion is to check for null pointer
before you free.  Do you happen to know which exception you got?

Thanks,
Binh-Minh
-------------
The HDF Group

-----Original Message-----
From: Hdf-forum [mailto:[email protected]] On Behalf Of sahon
Sent: Thursday, November 08, 2012 1:42 AM
To: [email protected]
Subject: [Hdf-forum] free memory for variable length types

Hello

I'm quite novice with HDF5 could you help me with attached code, i've used
sample codes, but unfortunately they do not work. Free memory for read
buffer causes exception. What is the best method to free memory? My version
of HDF is 1.8.9. Than you.

      Exception::dontPrint();
      H5File file( "filecpp.h5", H5F_ACC_TRUNC );
      hsize_t     dimsf[2];              // dataset dimensions
      dimsf[0] = 5;
      dimsf[1] = 5;
      DataSpace dataspace( 2, dimsf );
      IntType datatype( PredType::NATIVE_INT );
      datatype.setOrder( H5T_ORDER_LE );
      DataSet dataset = file.createDataSet("my dataset", datatype, dataspace
);

          StrType strArrType(PredType::C_S1,H5T_VARIABLE); 

          hsize_t dims[]={4};
                const char *string_att[4] = {"string1", 
                                    "str2", 
                                    "strings123", 
                                    "str45"};
                char* readStr[4];
                

                DataSpace dataspace2(1,dims);
                Attribute attr2=dataset.createAttribute("stringArray",
strArrType,
dataspace2);
                attr2.write(strArrType, string_att);

                attr2.read(strArrType, readStr);
                
                for (int i=0; i<4; i++)
                        free(readStr[i]); //causes exception



          file.close();



--
View this message in context:
http://hdf-forum.184993.n3.nabble.com/free-memory-for-variable-length-types-
tp4025565.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org


-- 
Internal Virus Database is out-of-date.
Checked by AVG. 
Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
2:14 PM


_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to