Skip to content

Commit 89a5863

Browse files
committed
modify handling for GSType* typeArr
1 parent 0d6928f commit 89a5863

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

src/gstype_python.i

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,58 +2029,36 @@ static bool getRowFields(GSRow* row, int columnCount, GSType* typeList, bool tim
20292029
$2[i] = numRowOfContainer;
20302030
$3[i] = convertObjToStr(containerName);
20312031
int length;
2032-
containerInfoTmp = arg1->get_container_info($3[i]);
2033-
if (containerInfoTmp == NULL) {
2034-
PyErr_SetString(PyExc_ValueError, "Not found container");
2035-
SWIG_fail;
2036-
}
2037-
infoListTmp = containerInfoTmp->get_column_info_list();
2038-
int* typeArr = (int*) malloc(infoListTmp.size * sizeof(int));
2039-
if (containerInfoTmp == NULL) {
2040-
PyErr_SetString(PyExc_ValueError, "Memory allocation error");
2041-
SWIG_fail;
2042-
}
2043-
if (typeArr == NULL) {
2044-
delete containerInfoTmp;
2045-
PyErr_SetString(PyExc_ValueError, "Memory allocation error");
2046-
SWIG_fail;
2047-
}
2048-
for (int m = 0; m < infoListTmp.size; m++) {
2049-
typeArr[m] = infoListTmp.columnInfo[m].type;
2050-
}
20512032
tmpContainer = arg1->get_container($3[i]);
20522033
if (tmpContainer == NULL) {
20532034
PyErr_SetString(PyExc_ValueError, "Not found container");
20542035
SWIG_fail;
20552036
}
2037+
GSType* typeArr = tmpContainer->getGSTypeList();
20562038
for (j = 0; j < numRowOfContainer; j++) {
20572039
PyObject* rowTmp = PyList_GetItem(listRowContainer, j);
20582040
if (!PyList_Check(rowTmp)) {
20592041
PyErr_SetString(PyExc_ValueError, "Expected a List");
2060-
free((void *) typeArr);
20612042
delete containerInfoTmp;
20622043
SWIG_fail;
20632044
}
20642045
length = (int)PyInt_AsLong(PyLong_FromSsize_t(PyList_Size(rowTmp)));
20652046
GSResult ret = gsCreateRowByContainer(tmpContainer->getGSContainerPtr(), &$1[i][j]);
20662047
if ($1[i][j] == NULL || ret != GS_RESULT_OK) {
20672048
PyErr_SetString(PyExc_ValueError, "Memory allocation error");
2068-
free((void *) typeArr);
20692049
delete containerInfoTmp;
20702050
SWIG_fail;
20712051
}
20722052
for (int k = 0; k < length; k++) {
2073-
if (!(convertToFieldWithType($1[i][j], k, PyList_GetItem(rowTmp, k), typeArr[k]))) {
2053+
if (!(convertToFieldWithType($1[i][j], k, PyList_GetItem(rowTmp, k), (int) typeArr[k]))) {
20742054
char gsType[200];
20752055
sprintf(gsType, "Invalid value for column %d, type should be : %d", k, typeArr[k]);
20762056
PyErr_SetString(PyExc_ValueError, gsType);
20772057
delete containerInfoTmp;
2078-
free((void *) typeArr);
20792058
SWIG_fail;
20802059
}
20812060
}
20822061
}
2083-
free((void *)typeArr);
20842062
delete containerInfoTmp;
20852063
delete tmpContainer;
20862064
i++;

0 commit comments

Comments
 (0)