detect when something tries to delete a callback that was never added
This commit is contained in:
10
src/atom.cpp
10
src/atom.cpp
@ -2044,9 +2044,7 @@ void Atom::delete_callback(const char *id, int flag)
|
||||
{
|
||||
if (id == NULL) return;
|
||||
|
||||
int ifix;
|
||||
for (ifix = 0; ifix < modify->nfix; ifix++)
|
||||
if (strcmp(id,modify->fix[ifix]->id) == 0) break;
|
||||
int ifix = modify->find_fix(id);
|
||||
|
||||
// compact the list of callbacks
|
||||
|
||||
@ -2054,6 +2052,8 @@ void Atom::delete_callback(const char *id, int flag)
|
||||
int match;
|
||||
for (match = 0; match < nextra_grow; match++)
|
||||
if (extra_grow[match] == ifix) break;
|
||||
if ((nextra_grow == 0) || (match == nextra_grow))
|
||||
error->all(FLERR,"Trying to delete non-existent Atom::grow() callback");
|
||||
for (int i = match; i < nextra_grow-1; i++)
|
||||
extra_grow[i] = extra_grow[i+1];
|
||||
nextra_grow--;
|
||||
@ -2062,6 +2062,8 @@ void Atom::delete_callback(const char *id, int flag)
|
||||
int match;
|
||||
for (match = 0; match < nextra_restart; match++)
|
||||
if (extra_restart[match] == ifix) break;
|
||||
if ((nextra_restart == 0) || (match == nextra_restart))
|
||||
error->all(FLERR,"Trying to delete non-existent Atom::restart() callback");
|
||||
for (int i = match; i < nextra_restart-1; i++)
|
||||
extra_restart[i] = extra_restart[i+1];
|
||||
nextra_restart--;
|
||||
@ -2070,6 +2072,8 @@ void Atom::delete_callback(const char *id, int flag)
|
||||
int match;
|
||||
for (match = 0; match < nextra_border; match++)
|
||||
if (extra_border[match] == ifix) break;
|
||||
if ((nextra_border == 0) || (match == nextra_border))
|
||||
error->all(FLERR,"Trying to delete non-existent Atom::border() callback");
|
||||
for (int i = match; i < nextra_border-1; i++)
|
||||
extra_border[i] = extra_border[i+1];
|
||||
nextra_border--;
|
||||
|
||||
Reference in New Issue
Block a user