return pstGroupName;
}
-char *createPathName(char *_pstGroupName, int _iIndex)
+char* createPathName(char *_pstGroupName, int _iIndex)
{
char *pstName = NULL;
char *pstPathName = NULL;
- pstName = (char *)MALLOC(((int)log10((double)(_iIndex + 1)) + 3) * sizeof(char));
+ int iNameLen = (int)log10((double)_iIndex + 1) + 1;
+ iNameLen += 2; //for both '#'
+ iNameLen += 1; //for null termanation
+
+ pstName = (char *)MALLOC(iNameLen * sizeof(char));
//1 for null termination, 2 for '#' characters
sprintf(pstName, "#%d#", _iIndex);
pstPathName = (char *)MALLOC((strlen(_pstGroupName) + strlen(pstName) + 2) * sizeof(char));
//1 for null termination, 1 for separator, 2 for '#' characters
sprintf(pstPathName, "%s/%s", _pstGroupName, pstName);
+ FREE(pstName);
return pstPathName;
}
herr_t status = 0;
hobj_ref_t iRef = 0;
- char *pstPathName = NULL;
-
- //createGroupe and dataset name
- pstPathName = createPathName(_pstGroupName, _iIndex);
-
if (_iRows * _iCols == 0)
{
double dblZero = 0;
}
else
{
+ char *pstPathName = NULL;
+
//Create dataspace. Setting maximum size to NULL sets the maximum
//size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return (hobj_ref_t) (-1);
}
+ //createGroupe and dataset name
+ pstPathName = createPathName(_pstGroupName, _iIndex);
+
//Create the dataset and write the array data to it.
iCompress = enableCompression(9, 1, dims);
dset = H5Dcreate(_iFile, pstPathName, H5T_NATIVE_DOUBLE, space, iCompress);
if (dset < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = H5Dwrite(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, _pdblData);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_DOUBLE);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addIntAttribute(dset, g_SCILAB_CLASS_ROWS, _iRows);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = addIntAttribute(dset, g_SCILAB_CLASS_COLS, _iCols);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
status = H5Rcreate(&iRef, _iFile, pstPathName, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstPathName);
return (hobj_ref_t) (-1);
}
+
+ FREE(pstPathName);
}
//Close and release resources.
return (hobj_ref_t) (-1);
}
- FREE(pstPathName);
-
return iRef;
}
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
pRef[0] = writeCommomDoubleMatrix(_iFile, pstGroupName, _pstDatasetName, 0, _iRows, _iCols, _pdblReal);
pRef[1] = writeCommomDoubleMatrix(_iFile, pstGroupName, _pstDatasetName, 1, _iRows, _iCols, _pdblImg);
+ FREE(pstGroupName);
if (pRef[0] == 0 || pRef[1] == 0)
{
return 1;
return -1;
}
- FREE(pstGroupName);
return 0;
}
hid_t iCompress = 0;
hobj_ref_t *pData = 0;
- char *pstName = NULL;
char *pstPathName = NULL;
-
char *pstGroupName = NULL;
// Create ref matrix
- pData = (hobj_ref_t *) MALLOC(_iRows * _iCols * sizeof(hobj_ref_t));
+ pData = (hobj_ref_t *)MALLOC(dims[0] * sizeof(hobj_ref_t));
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
//Now create each String as a dedicated DataSet.
- for (i = 0; i < _iRows * _iCols; i++)
+ for (i = 0 ; i < dims[0] ; i++)
{
pstPathName = createPathName(pstGroupName, i);
if (status < 0)
{
+ FREE(pstPathName);
+ FREE(pstGroupName);
+ FREE(pData);
return -1;
}
+
// create the ref
status = H5Rcreate(&pData[i], _iFile, pstPathName, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstPathName);
+ FREE(pstGroupName);
+ FREE(pData);
return -1;
}
- FREE(pstName);
FREE(pstPathName);
}
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
if (status < 0)
{
+ FREE(pData);
return -1;
}
dset = H5Dcreate(_iFile, _pstDatasetName, H5T_STD_REF_OBJ, space, iCompress);
if (dset < 0)
{
+ FREE(pData);
return -1;
}
status = H5Dwrite(dset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
if (status < 0)
{
+ FREE(pData);
return -1;
}
+
+ FREE(pData);
//Add attribute SCILAB_Class = poly to dataset
status = addAttribute(dset, g_SCILAB_CLASS, g_SCILAB_CLASS_POLY);
if (status < 0)
return -1;
}
- FREE(pstGroupName);
- FREE(pData);
-
return 0;
}
return writeCommonPolyMatrix(_iFile, _pstDatasetName, _pstVarName, 1, _iRows, _iCols, _piNbCoef, _pdblReal, _pdblImg);
}
-int writeInterger8Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, char *_pcData)
+int writeInteger8Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, char *_pcData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger16Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, short *_psData)
+int writeInteger16Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, short *_psData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger32Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int *_piData)
+int writeInteger32Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, int *_piData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
return 0;
}
-int writeInterger64Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, long long *_pllData)
+int writeInteger64Matrix(int _iFile, char *_pstDatasetName, int _iRows, int _iCols, long long *_pllData)
{
hsize_t piDims[1] = { _iRows * _iCols };
herr_t status = 0;
hid_t dset = 0;
hid_t group = 0;
hid_t iCompress = 0;
- hobj_ref_t *pDataRef = 0;
+ hobj_ref_t pDataRef[3] = {0};
char *pstRowPath = NULL;
char *pstColPath = NULL;
char *pstDataPath = NULL;
char *pstGroupName = NULL;
- // Create ref matrix
- //3 refs : 1 for data, 1 for Number Item by row ( row size ) and 1 for column position
- pDataRef = (hobj_ref_t *) MALLOC(3 * sizeof(hobj_ref_t));
-
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
//Create each sub dataset and insert data
pstRowPath = createPathName(pstGroupName, 0);
- status = writeInterger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
+ status = writeInteger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
pstColPath = createPathName(pstGroupName, 1);
- status = writeInterger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
+ status = writeInteger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
{
status = writeDoubleMatrix(_iFile, pstDataPath, 1, _iNbItem, _pdblReal);
}
+
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstDataPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[2], _iFile, pstDataPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstDataPath);
+ FREE(pstGroupName);
return -1;
}
FREE(pstRowPath);
FREE(pstColPath);
FREE(pstDataPath);
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return -1;
}
- FREE(pstGroupName);
-
return 0;
}
hid_t dset = 0;
hid_t group = 0;
hid_t iCompress = 0;
- hobj_ref_t *pDataRef = 0;
+ hobj_ref_t pDataRef[2] = {0};
char *pstRowPath = NULL;
char *pstColPath = NULL;
char *pstGroupName = NULL;
- // Create ref matrix
- //2 refs : 1 for data, 1 for Number Item by row ( row size ) and 1 for column position
- pDataRef = (hobj_ref_t *) MALLOC(2 * sizeof(hobj_ref_t));
-
// Generate groupname #<dataSetName>#
pstGroupName = createGroupName(_pstDatasetName);
status = H5Gclose(group);
if (status < 0)
{
+ FREE(pstGroupName);
return -1;
}
//Create each sub dataset and insert data
pstRowPath = createPathName(pstGroupName, 0);
- status = writeInterger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
+ status = writeInteger32Matrix(_iFile, pstRowPath, 1, _iRows, _piNbItemRow);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[0], _iFile, pstRowPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstGroupName);
return -1;
}
pstColPath = createPathName(pstGroupName, 1);
- status = writeInterger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
+ status = writeInteger32Matrix(_iFile, pstColPath, 1, _iNbItem, _piColPos);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
status = H5Rcreate(&pDataRef[1], _iFile, pstColPath, H5R_OBJECT, -1);
if (status < 0)
{
+ FREE(pstRowPath);
+ FREE(pstColPath);
+ FREE(pstGroupName);
return -1;
}
//FREE group names
FREE(pstRowPath);
FREE(pstColPath);
+ FREE(pstGroupName);
//Create dataspace. Setting maximum size to NULL sets the maximum size to be the current size.
space = H5Screate_simple(1, dims, NULL);
return -1;
}
- FREE(pstGroupName);
- FREE(pDataRef);
-
return 0;
}