Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Simon Marchi <simon.marchi@ericsson.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] tui: Simplify tui_alloc_content
Date: Tue, 22 Sep 2015 07:50:00 -0000	[thread overview]
Message-ID: <20150922075033.GB5430@embecosm.com> (raw)
In-Reply-To: <1442877416-16659-1-git-send-email-simon.marchi@ericsson.com>

* Simon Marchi <simon.marchi@ericsson.com> [2015-09-21 19:16:56 -0400]:

> 
> gdb/ChangeLog:
> 
> 	* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
> 	result.  Change type of element_block_ptr.  Change allocation to
> 	use XNEWVEC.
> ---
>  gdb/tui/tui-data.c | 41 ++++++++++++++---------------------------
>  1 file changed, 14 insertions(+), 27 deletions(-)
> 
> diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
> index 2fcd547..ca7502d 100644
> --- a/gdb/tui/tui-data.c
> +++ b/gdb/tui/tui-data.c
> @@ -573,40 +573,27 @@ tui_win_content
>  tui_alloc_content (int num_elements, enum tui_win_type type)
>  {
>    tui_win_content content;
> -  char *element_block_ptr;
> +  struct tui_win_element *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)
>      {
> -      /*
> -       * 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++)
>  	{
> -	  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;
> -	    }
> +	  content[i] = element_block_ptr;
> +	  init_content_element (content[i], type);
> +	  element_block_ptr++;
>  	}
>      }
> -
> -  return content;
>  }

Doesn't that leave the function without a return?

Thanks,
Andrew


       reply	other threads:[~2015-09-22  7:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1442877416-16659-1-git-send-email-simon.marchi@ericsson.com>
2015-09-22  7:50 ` Andrew Burgess [this message]
2015-09-22 14:53   ` Simon Marchi
2015-10-26 16:59 ` Simon Marchi
2015-10-26 22:05   ` Pedro Alves
2015-10-26 23:45     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150922075033.GB5430@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox