aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpollney <pollney@a491c6a4-70bf-4b89-8b36-d6c0cb1f094e>2003-04-08 11:58:13 +0000
committerpollney <pollney@a491c6a4-70bf-4b89-8b36-d6c0cb1f094e>2003-04-08 11:58:13 +0000
commit7f8aa4a2475a5975add181dc9cf418cf6ac02258 (patch)
tree6e751bafc3f2799529e76152c613c4852b5681be /src
parent9ca83c20f7cae7602264c4e02fc2ae95457c369e (diff)
Added some error return codes.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/SpaceMask/trunk@28 a491c6a4-70bf-4b89-8b36-d6c0cb1f094e
Diffstat (limited to 'src')
-rw-r--r--src/MaskUtils.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/MaskUtils.c b/src/MaskUtils.c
index 29a280a..0f51d4b 100644
--- a/src/MaskUtils.c
+++ b/src/MaskUtils.c
@@ -120,7 +120,10 @@ SpaceMask_get_free_bits(int nbits)
}
if (j<nbits)
- CCTK_WARN (0, "Cannot allocate mask: Not enough free bits.");
+ {
+ CCTK_WARN (1, "Cannot allocate mask: Not enough free bits.");
+ return 0;
+ }
return new_bits;
}
@@ -216,6 +219,10 @@ SpaceMask_setup_new_type(CCTK_INT new_bits, const char* type_name,
int j;
new_type = (SpaceMask_Type*) malloc (sizeof(SpaceMask_Type));
+
+ if (new_type == NULL)
+ return NULL;
+
new_type->bitmask = new_bits;
new_type->nstates = nstates;
new_type->name = type_name;
@@ -288,10 +295,16 @@ SpaceMask_RegisterType(const char* type_name, int nstates,
bit_nbr = SpaceMask_get_bit_nbr(nstates);
new_bits = SpaceMask_get_free_bits(bit_nbr);
+
+ if (new_bits == 0)
+ return -1;
+
state_mask = SpaceMask_determine_state_mask(new_bits, nstates);
new_type = SpaceMask_setup_new_type(new_bits, type_name, nstates,
state_list, state_mask);
+ if (new_type == NULL)
+ return -1;
SpaceMask_append_type_to_registry (new_type);
@@ -348,6 +361,10 @@ SpaceMask_AppendStatesToType(const char* type_name, int nstates,
SpaceMask_get_bit_nbr(old_type->nstates);
new_bits = SpaceMask_get_free_bits(new_bit_nbr);
+
+ if (new_bits == 0)
+ return -1;
+
allocated_bits = old_type->bitmask | new_bits;
state_mask = SpaceMask_determine_state_mask(allocated_bits, total_nstates);
@@ -362,6 +379,9 @@ SpaceMask_AppendStatesToType(const char* type_name, int nstates,
new_type = SpaceMask_setup_new_type(allocated_bits, type_name, total_nstates,
new_state_list, state_mask);
+ if (new_type == NULL)
+ return -1;
+
free(old_type);
spacemask_registry->type_list[old_type_idx] = new_type;