+
+#ifdef STACKCHECK
+
+static volatile int live_check_disable=0;
+
+void live_check(const char *file,int line)
+{
+static volatile char *top=NULL,*top_printed=NULL;
+static volatile size_t largest=0,largest_printed=0;
+volatile char mark;
+
+ if (&mark > top)
+ top=&mark;
+ if (live_check_disable<=0 && top!=top_printed) {
+ printf("live_check [%s:%d]: new top=0x%08lX\n",file,line,(long)top);
+ fflush(stdout);
+ top_printed=top;
+ }
+ if (largest < top-&mark)
+ largest = top-&mark;
+ if (live_check_disable<=0 && largest!=largest_printed) {
+ printf("live_check [%s:%d]: largest=%ld\n",file,line,(long)largest);
+ fflush(stdout);
+ largest_printed=largest;
+ }
+ if (largest >= 12000) {
+ if (live_check_disable<=0)
+ puts("live_check - aborting!");
+ _exit(99);
+ }
+}
+
+void live_disable(int how)
+{
+ live_check_disable+=how;
+}
+
+#endif /* STACKCHECK */