Logo Search packages:      
Sourcecode: iterm version File versions  Download package

VTScreenBuffer* VTScreenBuffer_new ( int  col,
int  row 
)

Constructor of Buffer object.

Parameters:
row number of rowss in the buffer. must be 0<
col number of columns in the rows. must be 0<
Returns:
reference to new buffer oject, if failed to create, return NULL

Definition at line 23 of file screen_buffer.c.

References _VTScreenBuf::attr, _VTScreenBuf::num_cols, _VTScreenBuf::num_rows, and _VTScreenBuf::rows.

{
  VTScreenBuffer *buf;
  int i;

  if(col <=0 || row <= 0)
      return NULL;
  
  if( (buf = (VTScreenBuffer *)malloc(sizeof(VTScreenBuffer))) == NULL )
  {
    perror("VTScreenBuffer_new\n");
    return NULL;
  }

  if( (buf->rows = (Row **)calloc(sizeof(Row *),row)) == NULL )
  {
    perror("VTScreenBuffer_new\n");
    free(buf);
    return NULL;

  }

  for(i=0;i<row;i++)
  {
    if ( (buf->rows[i] = Row_new(col)) == NULL )
        goto invalid;
  }

  buf->attr = 0;
  buf->num_cols = col;
  buf->num_rows = row;

  return buf;

  invalid:
  VTScreenBuffer_destroy(buf);
  return NULL;
}


Generated by  Doxygen 1.6.0   Back to index