* tests/test.c (mktree): Insert CHECK_OUT_OF_MEMORY to report mktree()
out-of-memory failures.
* tests/trace_test.c (mktree): Test whether GC_MALLOC_ATOMIC returns
NULL (exit with an error code and the appropriate message printed in
this case).
result -> lchild = mktree(n-1);
result -> rchild = mktree(n-1);
if (counter++ % 17 == 0 && n >= 2) {
- tn * tmp = result -> lchild -> rchild;
+ tn * tmp;
+ CHECK_OUT_OF_MEMORY(result->lchild);
+ tmp = result -> lchild -> rchild;
+ CHECK_OUT_OF_MEMORY(result->rchild);
result -> lchild -> rchild = result -> rchild -> lchild;
result -> rchild -> lchild = tmp;
}
#include <stdio.h>
+#include <stdlib.h>
#ifndef GC_DEBUG
# define GC_DEBUG
struct treenode * r = GC_MALLOC(sizeof(struct treenode));
if (0 == i) return 0;
if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+ if (r == NULL) {
+ printf("Out of memory\n");
+ exit(1);
+ }
r -> x = mktree(i-1);
r -> y = mktree(i-1);
return r;