/* wmexit.c (emx+gcc) -- Copyright (c) 1987-1994 by Eberhard Mattes */

#include <stdlib.h>
#include <sys/video.h>
#include <sys/winmgr.h>
#include "winmgr2.h"

void wm_exit (void)
{
  int i;
  wm_handle p;

  if (_wm_tab != NULL)
    {
      for (i = 0; i < _wm_max; ++i)
        {
          p = &_wm_tab[i];
          if (p->used == WM_USED)
            {
              _tfree (p->data);
              free (p->mask);
            }
        }
      free (_wm_tab);
      free (_wm_idx);
      _tfree (_wm_screen);
      _tfree (_wm_line);
      _wm_tab = NULL;
      _wm_idx = NULL;
      _wm_screen = NULL;
      _wm_idx = NULL;
      v_gotoxy (_wm_saved_x, _wm_saved_y);
      v_ctype (_wm_saved_cstart, _wm_saved_cend);
    }
}
