Skip to content

Commit

Permalink
fix a leak in the new DCLV code (rdkit#7279)
Browse files Browse the repository at this point in the history
  • Loading branch information
greglandrum authored Mar 21, 2024
1 parent 58023dd commit eebad84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Code/GraphMol/Descriptors/DCLV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,27 @@ struct State {
void freeAtomList(AtomList* ptr) {
while (ptr) {
AtomList* next = ptr->next;
#if 0
ptr->next = freeList;
freeList = ptr;
#else
free(ptr);
#endif
ptr = next;
}
}

void freeGrid() {
for (unsigned int x = 0; x < VOXORDER; x++) {
for (unsigned int y = 0; y < VOXORDER; y++) {
for (unsigned int z = 0; z < VOXORDER; z++) {
freeAtomList(grid[x][y][z]);
grid[x][y][z] = nullptr;
}
}
}
}

ElemStruct* getAtomElem(std::string atmName, bool typeFlag) {
const char* name = atmName.c_str();

Expand Down Expand Up @@ -856,6 +871,7 @@ DoubleCubicLatticeVolume::DoubleCubicLatticeVolume(const ROMol& mol,
vdwVolume = s.calculateVolume(0.0, memberAtoms);
compactness = calculateCompactness(surfaceArea, totalVolume);
packingDensity = (vdwVolume / totalVolume);
s.freeGrid();
}

} // namespace Descriptors
Expand Down
3 changes: 2 additions & 1 deletion Code/GraphMol/Descriptors/DCLV.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class RDKIT_DESCRIPTORS_EXPORT DoubleCubicLatticeVolume {
\param mol: input molecule or protein
\param isProtein: flag to identify input as protein vs unbound ligand
(default=true, Protein as input)
(default=true, Protein as input) NOTE that the results for isProtein=false
are currently not correct
\param includeLigand: flag to trigger
inclusion of bound ligand in surface area and volume calculations where
molecule is a protein [default false]
Expand Down
1 change: 1 addition & 0 deletions Code/GraphMol/Descriptors/Wrap/rdMolDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ BOOST_PYTHON_MODULE(rdMolDescriptors) {
docString =
R"DOC(ARGUMENTS:
" - mol: molecule or protein under consideration
" - isProtein: flag to indicate if the input is a protein (default=True). NOTE that results with isProtein=False are currently not correct.
" - includeLigand: flag to include or exclude a bound ligand when input is a protein (default=False)
" - probeRadius: radius of the solvent probe (default=1.4)
" - depth: control of number of dots per atom (default=2)
Expand Down

0 comments on commit eebad84

Please sign in to comment.