void Assert(int assertion, char* error) {
if(!assertion) {
- printf("Assertion Failed: %s\n",error);
- exit(-1);
+ fprintf(stderr, "Assertion Failed: %s\n",error);
+ longjmp(rb_jbuf, 1);
}
}
if ( (result = malloc(size)) ) { /* assignment intentional */
return(result);
} else {
- printf("memory overflow: malloc failed in SafeMalloc.");
- printf(" Exiting Program.\n");
- exit(-1);
+ fprintf(stderr, "memory overflow: malloc failed in SafeMalloc.");
+ /* printf(" Exiting Program.\n"); */
+ longjmp(rb_jbuf, 2);
return(0);
}
}
void (*InfoDestFunc) (void*),
void (*PrintFunc) (const void*),
void (*PrintInfo)(void*)) {
- rb_red_blk_tree* newTree;
+ rb_red_blk_tree* newTree = NULL;
rb_red_blk_node* temp;
+ if (setjmp(rb_jbuf)) {
+ if (newTree) {
+ if (newTree->nil) free (newTree->nil);
+ free (newTree);
+ }
+ return NULL;
+ }
newTree=(rb_red_blk_tree*) SafeMalloc(sizeof(rb_red_blk_tree));
+ newTree->nil = newTree->root = NULL;
newTree->Compare= CompFunc;
newTree->DestroyKey= DestFunc;
newTree->PrintKey= PrintFunc;
rb_red_blk_node * x;
rb_red_blk_node * newNode;
+ if (setjmp(rb_jbuf))
+ return NULL;
x=(rb_red_blk_node*) SafeMalloc(sizeof(rb_red_blk_node));
x->key=key;
x->info=info;
/***********************************************************************/
-/* FUNCTION: RBDEnumerate */
+/* FUNCTION: RBEnumerate */
/**/
/* INPUTS: tree is the tree to look for keys >= low */
/* and <= high with respect to the Compare function */
rb_red_blk_node* x=tree->root->left;
rb_red_blk_node* lastBest=nil;
+ if (setjmp(rb_jbuf)) {
+ return NULL;
+ }
enumResultStack=StackCreate();
while(nil != x) {
if ( 1 == (tree->Compare(x->key,high)) ) { /* x->key > high */
/* comment out the line below to remove all the debugging assertion */
/* checks from the compiled code. */
-#define DEBUG_ASSERT 1
+/* #define DEBUG_ASSERT 1 */
typedef struct rb_red_blk_node {
void* key;