From c5c55e2e7e07f6e3b354d9f05e766fd6df8f3cd4 Mon Sep 17 00:00:00 2001 From: schnetter Date: Fri, 5 Mar 2004 19:57:49 +0000 Subject: Fix array indexing bug in Bdry_Boundary_SelectedGVs when there are multiple bcdata_list objects. Perform some internal consistency checks. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@261 6a38eb6e-646e-4a02-a296-d141613ad6c4 --- src/Boundary.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Boundary.c b/src/Boundary.c index d9da8a3..5d2f7b3 100644 --- a/src/Boundary.c +++ b/src/Boundary.c @@ -895,7 +895,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH, CCTK_INT *table_handles, CCTK_STRING bc_name) { - int retval, i; + int retval, i, j; struct BCVAR *current; struct BCDATA *current_bcdata; const cGH *GH = _GH; @@ -922,6 +922,8 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH, bc_name, array_size); fflush(stdout); #endif + i = 0; /* i indexes the location in the returned arrays */ + /* Step through bcdata list */ for (current_bcdata = bcdata_list; current_bcdata; @@ -940,7 +942,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH, current = current_bcdata->var_list; /* Loop through var list */ - for (i=0; /* i indexes the location in the returned arrays */ + for (j=0; /* j counts the bcs to check internal consistency */ inext, ++i) { @@ -968,6 +970,8 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER_TO_CONST _GH, ((int *) var_indices)[i] = current->var; } } + if (j > current_bcdata->num) CCTK_WARN (0, "internal error"); + if (i != array_size && j != current_bcdata->num) CCTK_WARN (0, "internal error"); } } -- cgit v1.2.3