This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] tui, clean up long lines and xmallocs


> Date: Tue, 31 Jul 2007 16:45:12 -0700 (PDT)
> From: msnyder@sonic.net

> 2007-07-31  Michael Snyder  <msnyder@svkmacdonelllnx>
> 
> 	* tui/tui-data.c (tui_alloc_content): Move assign out of if, 
> 	clean up long lines.
> 	(tui_alloc_generic_win_info): Tidy by using XMALLOC macro.
> 	(tui_alloc_win_info): Ditto.
> 	(tui_add_content_elements): Ditto.
> 	* tui/tui-file.c (tui_file_magic): Ditto.

Looks ok to me, but:

> Index: tui-data.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/tui/tui-data.c,v
> retrieving revision 1.15
> diff -p -r1.15 tui-data.c
> *** tui-data.c	28 Jul 2007 01:16:39 -0000	1.15
> --- tui-data.c	31 Jul 2007 23:40:21 -0000
> *************** tui_alloc_win_info (enum tui_win_type ty
> *** 570,577 ****
>   {
>     struct tui_win_info * win_info = (struct tui_win_info *) NULL;
>   
> !   win_info = (struct tui_win_info *) xmalloc (sizeof (struct tui_win_info));
> !   if ((win_info != NULL))
>       {
>         win_info->generic.type = type;
>         init_win_info (win_info);
> --- 569,576 ----
>   {
>     struct tui_win_info * win_info = (struct tui_win_info *) NULL;
>   
> !   win_info = XMALLOC (struct tui_win_info);
> !   if (win_info != NULL)
>       {
>         win_info->generic.type = type;
>         init_win_info (win_info);

While you're there, you might as well remove that redundant
initialization on the line above.

> *************** tui_alloc_content (int num_elements, enu
> *** 589,605 ****
>     char *element_block_ptr = (char *) NULL;
>     int i;
>   
> !   if ((content = (tui_win_content)
> !   xmalloc (sizeof (struct tui_win_element *) * num_elements)) != (tui_win_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)
>   	{
> ! 	  if ((element_block_ptr = (char *)
> ! 	   xmalloc (sizeof (struct tui_win_element) * num_elements)) != (char *) NULL)
>   	    {
>   	      for (i = 0; i < num_elements; i++)
>   		{
> --- 588,607 ----
>     char *element_block_ptr = (char *) NULL;
>     int i;
>   
> !   content = xmalloc (sizeof (struct tui_win_element *) * num_elements);

Similar here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]