/* ccatch.c
 *
 * Copyright Niels Möller <nisse@lysator.liu.se> 1995
 *
 * Freely distributable under the terms and conditions of the
 * GNU General Public License.
 */

#include <ccatch.h>
#include <stdio.h>
#include <stdlib.h>

struct frame_stack the_frame_stack;

int ccatch_cleanup_on_exit;

static void
catch_on_exit(void)
{
  if (ccatch_cleanup_on_exit)
    {
      frstack_unwind(NULL, 1);
      frstack_free(NULL);
    }
}


void
init_ccatch(void)
{
  frstack_init();

  if (atexit(catch_on_exit) != 0)
    {
      fprintf(stderr, "init_catch: atexit() failed!\n");
      exit(EXIT_FAILURE);
    }
  ccatch_cleanup_on_exit = 1;
}
