This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] tui, clean up long lines and xmallocs
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: msnyder at sonic dot net
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 1 Aug 2007 09:58:59 +0200 (CEST)
- Subject: Re: [PATCH] tui, clean up long lines and xmallocs
- References: <15296.12.7.175.2.1185925512.squirrel@webmail.sonic.net>
> 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.