#include #include /**** class stuff ****/ class mask { public: FIELD *m_fields[2]; FORM *m_form; WINDOW *m_win; mask(); ~mask(); }; mask::mask() { initscr(); m_win= newwin(3, 44, LINES/2-1, COLS/2-22); m_fields[0] = new_field(1, 32, 0, 0, 0, 0); m_fields[1] = NULL; m_form= new_form(m_fields); set_form_win(m_form, m_win); set_form_sub(m_form, derwin(m_win, 1, 32, 1, 11)); } mask::~mask() { free_form(m_form); // Comment this line to stop infinite looping free_field(m_fields[0]); delwin(m_win); endwin(); } /**** same stuff in function ****/ void maskfunction() { FIELD *m_fields[2]; FORM *m_form; WINDOW *m_win; initscr(); m_win= newwin(3, 44, LINES/2-1, COLS/2-22); m_fields[0] = new_field(1, 32, 0, 0, 0, 0); m_fields[1] = NULL; m_form= new_form(m_fields); set_form_win(m_form, m_win); set_form_sub(m_form, derwin(m_win, 1, 32, 1, 11)); free_form(m_form); // No problem with that in a simple function free_field(m_fields[0]); delwin(m_win); endwin(); } /**** main ****/ int main() { // no if() - no looping, even if free_form() in class is used if (1) { // maskfunction(); // works fine without an object mask omask; omask.~mask(); } char *arr= new char[1024]; // This is the point where the looping begins // the malloc() syscall causes it - dunno why delete arr; return 0; }