Add pointer check after each newwin/subwin with error diagnostic

This commit is contained in:
Andrey A. Chernov 1994-10-31 04:02:31 +00:00
parent bb5e714cf2
commit 9570a6deea
8 changed files with 60 additions and 0 deletions

View File

@ -59,6 +59,11 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
@ -91,6 +96,11 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in
/* create new window for the list */
list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1);
if (list == NULL) {
endwin();
fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height,list_width,y+box_y+1,x+box_x+1);
exit(1);
}
keypad(list, TRUE);
/* draw a box around the list items */

View File

@ -42,6 +42,11 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);

View File

@ -49,6 +49,11 @@ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int wid
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
@ -81,6 +86,11 @@ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int wid
/* create new window for the menu */
menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1);
if (menu == NULL) {
endwin();
fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", menu_height,menu_width,y+box_y+1,x+box_x+1);
exit(1);
}
keypad(menu, TRUE);
/* draw a box around the menu items */

View File

@ -41,6 +41,11 @@ int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int w
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);

View File

@ -43,6 +43,11 @@ int dialog_prgbox(unsigned char *title, const char *line, int height, int width,
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);

View File

@ -67,6 +67,11 @@ int dialog_radiolist(char *title, char *prompt, int height, int width, int list_
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
@ -99,6 +104,11 @@ int dialog_radiolist(char *title, char *prompt, int height, int width, int list_
/* create new window for the list */
list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1);
if (list == NULL) {
endwin();
fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height,list_width,y+box_y+1,x+box_x+1);
exit(1);
}
keypad(list, TRUE);
/* draw a box around the list items */

View File

@ -92,11 +92,21 @@ int dialog_textbox(unsigned char *title, unsigned char *file, int height, int wi
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
/* Create window for text region, used for scrolling text */
/* text = newwin(height-4, width-2, y+1, x+1); */
text = subwin(dialog, height-4, width-2, y+1, x+1);
if (text == NULL) {
endwin();
fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", height-4,width-2,y+1,x+1);
exit(1);
}
keypad(text, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);

View File

@ -40,6 +40,11 @@ int dialog_yesno(unsigned char *title, unsigned char * prompt, int height, int w
draw_shadow(stdscr, y, x, height, width);
#endif
dialog = newwin(height, width, y, x);
if (dialog == NULL) {
endwin();
fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x);
exit(1);
}
keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);