示例#1
0
文件: tui-data.c 项目: ChrisG0x20/gdb
/* Adds the input number of elements to the windows's content.  If no
   content has been allocated yet, alloc_content() is called to do
   this.  The index of the first element added is returned, unless
   there is a memory allocation error, in which case, (-1) is
   returned.  */
int
tui_add_content_elements (struct tui_gen_win_info *win_info, 
			  int num_elements)
{
  struct tui_win_element *element_ptr;
  int i, index_start;

  if (win_info->content == NULL)
    {
      win_info->content = tui_alloc_content (num_elements, win_info->type);
      index_start = 0;
    }
  else
    index_start = win_info->content_size;
  if (win_info->content != NULL)
    {
      for (i = index_start; (i < num_elements + index_start); i++)
	{
	  element_ptr = XNEW (struct tui_win_element);
	  if (element_ptr != NULL)
	    {
	      win_info->content[i] = element_ptr;
	      init_content_element (element_ptr, win_info->type);
	      win_info->content_size++;
	    }
	  else	/* Things must be really hosed now!  We ran out of
		   memory!?  */
	    return (-1);
	}
    }

  return index_start;
}
示例#2
0
/* Allocates the content and elements in a block.  */
tui_win_content
tui_alloc_content (int num_elements, enum tui_win_type type)
{
  tui_win_content content;
  struct tui_win_element *element_block_ptr;
  int i;

  content = XNEWVEC (struct tui_win_element *, num_elements);

  /*
   * All windows, except the data window, can allocate the
   * elements in a chunk.  The data window cannot because items
   * can be added/removed from the data display by the user at any
   * time.
   */
  if (type != DATA_WIN)
    {
      element_block_ptr = XNEWVEC (struct tui_win_element, num_elements);
      for (i = 0; i < num_elements; i++)
	{
	  content[i] = element_block_ptr;
	  init_content_element (content[i], type);
	  element_block_ptr++;
	}
    }
示例#3
0
文件: tui-data.c 项目: ChrisG0x20/gdb
/* Allocates the content and elements in a block.  */
tui_win_content
tui_alloc_content (int num_elements, enum tui_win_type type)
{
  tui_win_content content;
  char *element_block_ptr;
  int i;

  content = XNEWVEC (struct tui_win_element *, num_elements);
  if (content != NULL)
    {
      /*
       * All windows, except the data window, can allocate the
       * elements in a chunk.  The data window cannot because items
       * can be added/removed from the data display by the user at any
       * time.
       */
      if (type != DATA_WIN)
	{
	  element_block_ptr =
	    xmalloc (sizeof (struct tui_win_element) * num_elements);
	  if (element_block_ptr != NULL)
	    {
	      for (i = 0; i < num_elements; i++)
		{
		  content[i] = (struct tui_win_element *) element_block_ptr;
		  init_content_element (content[i], type);
		  element_block_ptr += sizeof (struct tui_win_element);
		}
	    }
	  else
	    {
	      xfree (content);
	      content = (tui_win_content) NULL;
	    }
	}
    }

  return content;
}