diff options
author | rideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4> | 2003-05-14 14:44:34 +0000 |
---|---|---|
committer | rideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4> | 2003-05-14 14:44:34 +0000 |
commit | f7a364131e9fb50df18959975473a42de6da8770 (patch) | |
tree | 9f333d358d87c439845e28222b55b1cc8bf12a6e /src/ScalarBoundary.c | |
parent | 6fa8e9ba378c8037676bbdab7d51d984fb00e674 (diff) |
Take advantage of fact that free and realloc can handle null pointers
to simplify code.
Fixes CactusBase/1509.
Also fixes bug in reallocation of width_alldirs[].
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@234 6a38eb6e-646e-4a02-a296-d141613ad6c4
Diffstat (limited to 'src/ScalarBoundary.c')
-rw-r--r-- | src/ScalarBoundary.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/ScalarBoundary.c b/src/ScalarBoundary.c index 49ad95c..0dba2af 100644 --- a/src/ScalarBoundary.c +++ b/src/ScalarBoundary.c @@ -157,13 +157,9 @@ int BndScalar(const cGH *GH, int num_vars, int *vars, int *faces, int *widths, /* Determine boundary width on all faces */ /* allocate memory for buffer */ gdim = CCTK_GroupDimI(gi); - if (!width_alldirs) + if (gdim > max_gdim) { - width_alldirs = (int *) malloc(2*gdim*sizeof(int)); - max_gdim = gdim; - } else if (gdim > max_gdim) - { - width_alldirs = realloc(width_alldirs, gdim*sizeof(int)); + width_alldirs = realloc(width_alldirs, 2*gdim*sizeof(int)); max_gdim = gdim; } |