Merge pull request #668 from ovilab/modify_deallocation_fix

Fixed proper deletion of fixes if fix is NULL
This commit is contained in:
Steve Plimpton 2017-10-05 17:00:10 -06:00 committed by GitHub
commit 7a90eef527
2 changed files with 9 additions and 2 deletions

View File

@ -110,7 +110,7 @@ Modify::~Modify()
// delete all fixes
// do it via delete_fix() so callbacks in Atom are also updated correctly
while (nfix) delete_fix(fix[0]->id);
while (nfix) delete_fix(0);
memory->sfree(fix);
memory->destroy(fmask);
@ -944,7 +944,13 @@ void Modify::delete_fix(const char *id)
{
int ifix = find_fix(id);
if (ifix < 0) error->all(FLERR,"Could not find fix ID to delete");
delete fix[ifix];
delete_fix(ifix);
}
void Modify::delete_fix(int ifix)
{
if(fix[ifix])
delete fix[ifix];
atom->update_callback(ifix);
// move other Fixes and fmask down in list one slot

View File

@ -95,6 +95,7 @@ class Modify : protected Pointers {
void add_fix(int, char **, int trysuffix=1);
void modify_fix(int, char **);
void delete_fix(const char *);
void delete_fix(int);
int find_fix(const char *);
int find_fix_by_style(const char *);
int check_package(const char *);