Skip to content

Commit

Permalink
Fix for foldcomp.get_data()
Browse files Browse the repository at this point in the history
  • Loading branch information
khb7840 committed Mar 29, 2023
1 parent 7324309 commit dd99945
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions foldcomp/foldcomp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ PyObject* getPyDictFromFoldcomp(Foldcomp* fcmp, const std::vector<float3d>& coor
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for Python dictionary");
return NULL;
}
PyObject* result = NULL;

// Dictionary keys: phi, psi, omega, torsion_angles, residues, bond_angles, coordinates
// Convert vectors to Python lists
Expand Down Expand Up @@ -571,22 +570,17 @@ PyObject* getPyDictFromFoldcomp(Foldcomp* fcmp, const std::vector<float3d>& coor
PyDict_SetItemString(dict, "b_factors", b_factors);
PyDict_SetItemString(dict, "coordinates", coordinates);

result = dict;
// Free memory
Py_XDECREF(phi);
Py_XDECREF(psi);
Py_XDECREF(omega);
Py_XDECREF(torsion_angles);
Py_XDECREF(bond_angles);
Py_XDECREF(residues);
Py_XDECREF(b_factors);
Py_XDECREF(coordinates);

if (result == NULL) {
Py_XDECREF(dict);
Py_XDECREF(phi);
Py_XDECREF(psi);
Py_XDECREF(omega);
Py_XDECREF(torsion_angles);
Py_XDECREF(bond_angles);
Py_XDECREF(residues);
Py_XDECREF(b_factors);
Py_XDECREF(coordinates);
return NULL;
}

return result;
return dict;
}

// Extract
Expand Down Expand Up @@ -659,6 +653,7 @@ PyObject* getDataFromPDB(const std::string& pdb_input) {
if (dict == NULL) {
return NULL;
}
// Free memory
return dict;
}

Expand Down

0 comments on commit dd99945

Please sign in to comment.