This commit is contained in:
Ricardo Rodriguez
2025-02-19 23:59:30 -05:00
committed by GitHub
parent ed4a44280a
commit 1a67fefcc6
3 changed files with 23 additions and 30 deletions

View File

@@ -1760,7 +1760,7 @@ std::string MolToInchi(const ROMol &mol, ExtraInchiReturnValues &rv,
unsigned int nBonds = m->getNumBonds();
// Make array of inchi_atom (storage space)
auto *inchiAtoms = new inchi_Atom[nAtoms];
std::unique_ptr<inchi_Atom[]> inchiAtoms(new inchi_Atom[nAtoms]);
// and a vector for stereo0D
std::vector<inchi_Stereo0D> stereo0DEntries;
@@ -2048,24 +2048,23 @@ std::string MolToInchi(const ROMol &mol, ExtraInchiReturnValues &rv,
}
// create stereo0D
inchi_Stereo0D *stereo0Ds;
std::unique_ptr<inchi_Stereo0D[]> stereo0Ds;
if (stereo0DEntries.size()) {
stereo0Ds = new inchi_Stereo0D[stereo0DEntries.size()];
stereo0Ds.reset(new inchi_Stereo0D[stereo0DEntries.size()]);
for (unsigned int i = 0; i < stereo0DEntries.size(); i++) {
stereo0Ds[i] = stereo0DEntries[i];
}
} else {
stereo0Ds = nullptr;
}
// create input
inchi_Input input;
input.atom = inchiAtoms;
input.stereo0D = stereo0Ds;
input.atom = inchiAtoms.get();
input.stereo0D = stereo0Ds.get();
std::unique_ptr<char[]> _options;
if (options) {
char *_options = new char[strlen(options) + 1];
fixOptionSymbol(options, _options);
input.szOptions = _options;
_options.reset(new char[strlen(options) + 1]);
fixOptionSymbol(options, _options.get());
input.szOptions = _options.get();
} else {
input.szOptions = nullptr;
}
@@ -2098,14 +2097,6 @@ std::string MolToInchi(const ROMol &mol, ExtraInchiReturnValues &rv,
// clean up
FreeINCHI(&output);
}
if (input.szOptions) {
delete[] input.szOptions;
}
delete[] inchiAtoms;
if (stereo0Ds) {
delete[] stereo0Ds;
}
return inchi;
}
@@ -2153,7 +2144,9 @@ std::string InchiToInchiKey(const std::string &inchi) {
char inchiKey[29];
char xtra1[65], xtra2[65];
int ret = 0;
{ ret = GetINCHIKeyFromINCHI(inchi.c_str(), 0, 0, inchiKey, xtra1, xtra2); }
{
ret = GetINCHIKeyFromINCHI(inchi.c_str(), 0, 0, inchiKey, xtra1, xtra2);
}
std::string error;
switch (ret) {
case INCHIKEY_OK: