aboutsummaryrefslogtreecommitdiff
path: root/src/IndexArrays.c
diff options
context:
space:
mode:
authorhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2003-11-19 10:50:28 +0000
committerhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2003-11-19 10:50:28 +0000
commit0bf22e6b0b00d179e48e2f0fd228ff72df1e647d (patch)
treeff02f4038a90425716d2d43e4a7a13c4e27b4634 /src/IndexArrays.c
parent0d8fa0e98fd7044534cf385e0e063a8435118718 (diff)
Check that we don't try to allocate zero size arrays.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@42 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src/IndexArrays.c')
-rw-r--r--src/IndexArrays.c212
1 files changed, 123 insertions, 89 deletions
diff --git a/src/IndexArrays.c b/src/IndexArrays.c
index faeaec7..5c3edcd 100644
--- a/src/IndexArrays.c
+++ b/src/IndexArrays.c
@@ -87,145 +87,179 @@ void MoL_SetupIndexArrays(CCTK_ARGUMENTS)
return;
}
- EvolvedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
- sizeof(CCTK_INT));
- if (!EvolvedVariableIndex)
- {
- CCTK_WARN(0,"Failed to allocate the evolved variable index array");
- }
-
- RHSVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
- sizeof(CCTK_INT));
- if (!RHSVariableIndex)
+
+ if (MoL_Num_Evolved_Vars)
{
- CCTK_WARN(0,"Failed to allocate the RHS variable index array");
+ EvolvedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
+ sizeof(CCTK_INT));
+ if (!EvolvedVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the evolved variable index array");
+ }
+
+ RHSVariableIndex = (CCTK_INT *)malloc(MoL_Num_Evolved_Vars *
+ sizeof(CCTK_INT));
+ if (!RHSVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the RHS variable index array");
+ }
}
- ConstrainedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Constrained_Vars *
- sizeof(CCTK_INT));
- if (!ConstrainedVariableIndex)
+ if (MoL_Num_Constrained_Vars)
{
- CCTK_WARN(0,"Failed to allocate the constrained variable index array");
+ ConstrainedVariableIndex = (CCTK_INT *)malloc(MoL_Num_Constrained_Vars *
+ sizeof(CCTK_INT));
+ if (!ConstrainedVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the constrained variable index array");
+ }
}
- SandRVariableIndex = (CCTK_INT *)malloc(MoL_Num_SaveAndRestore_Vars *
- sizeof(CCTK_INT));
- if (!SandRVariableIndex)
+ if (MoL_Num_SaveAndRestore_Vars)
{
- CCTK_WARN(0,"Failed to allocate the save and restore "
- "variable index array");
+ SandRVariableIndex = (CCTK_INT *)malloc(MoL_Num_SaveAndRestore_Vars *
+ sizeof(CCTK_INT));
+ if (!SandRVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the save and restore "
+ "variable index array");
+ }
}
-
if (EvolvedComplexVariableIndex)
{
return;
}
- EvolvedComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexEvolved_Vars *
- sizeof(CCTK_INT));
- if (!EvolvedComplexVariableIndex)
- {
- CCTK_WARN(0,"Failed to allocate the evolved complex variable index array");
- }
-
- RHSComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexEvolved_Vars *
- sizeof(CCTK_INT));
- if (!RHSComplexVariableIndex)
+ if (MoL_Num_ComplexEvolved_Vars)
{
- CCTK_WARN(0,"Failed to allocate the RHS complex variable index array");
+ EvolvedComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!EvolvedComplexVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the evolved complex variable index array");
+ }
+
+ RHSComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!RHSComplexVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the RHS complex variable index array");
+ }
}
- ConstrainedComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexConstrained_Vars *
- sizeof(CCTK_INT));
- if (!ConstrainedComplexVariableIndex)
+ if (MoL_Num_ComplexConstrained_Vars)
{
- CCTK_WARN(0,"Failed to allocate the constrained complex "
- "variable index array");
+ ConstrainedComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexConstrained_Vars *
+ sizeof(CCTK_INT));
+ if (!ConstrainedComplexVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the constrained complex "
+ "variable index array");
+ }
}
- SandRComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexSaveAndRestore_Vars *
- sizeof(CCTK_INT));
- if (!SandRComplexVariableIndex)
+ if (MoL_Num_ComplexSaveAndRestore_Vars)
{
- CCTK_WARN(0,"Failed to allocate the save and restore complex "
- "variable index array");
- }
-
+ SandRComplexVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexSaveAndRestore_Vars *
+ sizeof(CCTK_INT));
+ if (!SandRComplexVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the save and restore complex "
+ "variable index array");
+ }
+ }
if (EvolvedArrayVariableIndex)
{
return;
}
- EvolvedArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayEvolved_Vars *
- sizeof(CCTK_INT));
- if (!EvolvedArrayVariableIndex)
+ if (MoL_Num_ArrayEvolved_Vars)
{
- CCTK_WARN(0,"Failed to allocate the evolved array variable index array");
- }
+ EvolvedArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!EvolvedArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the evolved array variable index array");
+ }
- RHSArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayEvolved_Vars *
- sizeof(CCTK_INT));
- if (!RHSArrayVariableIndex)
- {
- CCTK_WARN(0,"Failed to allocate the RHS array variable index array");
+ RHSArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!RHSArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the RHS array variable index array");
+ }
}
- ConstrainedArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayConstrained_Vars *
- sizeof(CCTK_INT));
- if (!ConstrainedArrayVariableIndex)
+ if (MoL_Num_ArrayConstrained_Vars)
{
- CCTK_WARN(0,"Failed to allocate the constrained array "
- "variable index array");
+ ConstrainedArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArrayConstrained_Vars *
+ sizeof(CCTK_INT));
+ if (!ConstrainedArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the constrained array "
+ "variable index array");
+ }
}
- SandRArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArraySaveAndRestore_Vars *
- sizeof(CCTK_INT));
- if (!SandRArrayVariableIndex)
+ if (MoL_Num_ArraySaveAndRestore_Vars)
{
- CCTK_WARN(0,"Failed to allocate the save and restore "
- "array variable index array");
+ SandRArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ArraySaveAndRestore_Vars *
+ sizeof(CCTK_INT));
+ if (!SandRArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the save and restore "
+ "array variable index array");
+ }
}
-
if (EvolvedComplexArrayVariableIndex)
{
return;
}
- EvolvedComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayEvolved_Vars *
- sizeof(CCTK_INT));
- if (!EvolvedComplexArrayVariableIndex)
- {
- CCTK_WARN(0,"Failed to allocate the evolved complex "
- "array variable index array");
- }
-
- RHSComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayEvolved_Vars *
- sizeof(CCTK_INT));
- if (!RHSComplexArrayVariableIndex)
+ if (MoL_Num_ComplexArrayEvolved_Vars)
{
- CCTK_WARN(0,"Failed to allocate the RHS complex array "
- "variable index array");
+ EvolvedComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!EvolvedComplexArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the evolved complex "
+ "array variable index array");
+ }
+
+ RHSComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayEvolved_Vars *
+ sizeof(CCTK_INT));
+ if (!RHSComplexArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the RHS complex array "
+ "variable index array");
+ }
}
- ConstrainedComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayConstrained_Vars *
- sizeof(CCTK_INT));
- if (!ConstrainedComplexArrayVariableIndex)
+ if (MoL_Num_ComplexArrayConstrained_Vars)
{
- CCTK_WARN(0,"Failed to allocate the constrained complex "
- "array variable index array");
+ ConstrainedComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArrayConstrained_Vars *
+ sizeof(CCTK_INT));
+ if (!ConstrainedComplexArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the constrained complex "
+ "array variable index array");
+ }
}
- SandRComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArraySaveAndRestore_Vars *
- sizeof(CCTK_INT));
- if (!SandRComplexArrayVariableIndex)
+ if (MoL_Num_ComplexArraySaveAndRestore_Vars)
{
- CCTK_WARN(0,"Failed to allocate the save and restore "
- "complex array variable index array");
+ SandRComplexArrayVariableIndex = (CCTK_INT *)malloc(MoL_Num_ComplexArraySaveAndRestore_Vars *
+ sizeof(CCTK_INT));
+ if (!SandRComplexArrayVariableIndex)
+ {
+ CCTK_WARN(0,"Failed to allocate the save and restore "
+ "complex array variable index array");
+ }
}
-
+
infoline = (char *)malloc((strlen(Generic_Method_Descriptor)+100)*
sizeof(char));
if (!infoline)