Annotation of researchv10no/ncurses/screen/newwin.c, revision 1.1.1.1

1.1       root        1: # include      "curses.ext"
                      2: # include      <signal.h>
                      3: /*     @(#) newwin.c: 1.1 10/15/83     (1.17   3/16/83)        */
                      4: 
                      5: char   *calloc();
                      6: char   *malloc();
                      7: extern char    *getenv();
                      8: 
                      9: extern WINDOW  *makenew();
                     10: 
                     11: /*
                     12:  * allocate space for and set up defaults for a new _window
                     13:  *
                     14:  * 1/26/81 (Berkeley).  This used to be newwin.c
                     15:  */
                     16: 
                     17: WINDOW *
                     18: newwin(nlines, ncols, by, bx)
                     19: register int   nlines, ncols, by, bx;
                     20: {
                     21:        register WINDOW *win;
                     22:        register chtype *sp;
                     23:        register int i;
                     24:        char *calloc();
                     25: 
                     26:        if (by + nlines > LINES)
                     27:                nlines = LINES - by;
                     28:        if (bx + ncols > COLS)
                     29:                ncols = COLS - bx;
                     30: 
                     31:        if (nlines == 0)
                     32:                nlines = LINES - by;
                     33:        if (ncols == 0)
                     34:                ncols = COLS - bx;
                     35: 
                     36:        if ((win = makenew(nlines, ncols, by, bx)) == NULL)
                     37:                return NULL;
                     38:        for (i = 0; i < nlines; i++)
                     39:                if ((win->_y[i] = (chtype *) calloc(ncols, sizeof (chtype))) == NULL) {
                     40:                        register int j;
                     41: 
                     42:                        for (j = 0; j < i; j++)
                     43:                                cfree((char *)win->_y[j]);
                     44:                        cfree((char *)win->_firstch);
                     45:                        cfree((char *)win->_lastch);
                     46:                        cfree((char *)win->_y);
                     47:                        cfree((char *)win);
                     48:                        return NULL;
                     49:                }
                     50:                else
                     51:                        for (sp = win->_y[i]; sp < win->_y[i] + ncols; )
                     52:                                *sp++ = ' ';
                     53:        return win;
                     54: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.