This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH] ada-lang.c, ada-tasks.c: replace free() and malloc() calls


This patch fixes regressions in ada-tasks.c and ada-lang.c caused by
the use of free and malloc instead of xfree() and xmalloc().

Commited as obvious.

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.2904
diff -c -3 -r1.2904 ChangeLog
*** gdb/ChangeLog	13 Jul 2002 00:29:37 -0000	1.2904
--- gdb/ChangeLog	13 Jul 2002 01:29:24 -0000
***************
*** 1,3 ****
--- 1,13 ----
+ 2002-07-13  Aidan Skinner <aidan@velvet.net>
+ 
+ 	* ada-tasks.c (add_task_entry): replace calls to
+ 	malloc() with xmalloc
+ 	* ada-tasks.c (init_task_list): replace calls to free with xfree()
+ 	
+ 	* ada-lang.c (replace_operator_with_call, fill_in_ada_prototype,
+ 	ada_finish_decode_line_1, all_sals_for_line
+ 	ada_breakpoint_rewrite): replace calls to free() with xfree()
+ 		
  2002-07-12  Kevin Buettner  <kevinb@redhat.com>
  
  	From Nicholas Duffek (with minor changes by Martin Hunt, 
Index: gdb/ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.3
diff -c -3 -r1.3 ada-lang.c
*** gdb/ada-lang.c	11 Jul 2002 20:46:18 -0000	1.3
--- gdb/ada-lang.c	13 Jul 2002 01:29:33 -0000
***************
*** 2891,2897 ****
    newexp->elts[pc + 5].symbol = sym;
  
    *expp = newexp;
!   free (exp);
  }  
  
  /* Type-class predicates */
--- 2891,2897 ----
    newexp->elts[pc + 5].symbol = sym;
  
    *expp = newexp;
!   xfree (exp);
  }  
  
  /* Type-class predicates */
***************
*** 4363,4369 ****
    if (nargs == 0)
      {
        static struct field dummy_field = {0, 0, 0, 0};
!       free (TYPE_FIELDS (ftype));
        TYPE_FIELDS (ftype) = &dummy_field;
      }
    else
--- 4363,4369 ----
    if (nargs == 0)
      {
        static struct field dummy_field = {0, 0, 0, 0};
!       xfree (TYPE_FIELDS (ftype));
        TYPE_FIELDS (ftype) = &dummy_field;
      }
    else
***************
*** 4373,4379 ****
        memcpy ((char*) fields, 
  	      (char*) TYPE_FIELDS (ftype), 
  	      nargs * sizeof (struct field));
!       free (TYPE_FIELDS (ftype));
        TYPE_FIELDS (ftype) = fields;
      }
  }
--- 4373,4379 ----
        memcpy ((char*) fields, 
  	      (char*) TYPE_FIELDS (ftype), 
  	      nargs * sizeof (struct field));
!       xfree (TYPE_FIELDS (ftype));
        TYPE_FIELDS (ftype) = fields;
      }
  }
***************
*** 4586,4592 ****
    selected.sals = (struct symtab_and_line*) 
      xmalloc (sizeof (struct symtab_and_line) * selected.nelts);
    memset (selected.sals, 0, selected.nelts * sizeof (selected.sals[i]));
!   make_cleanup (free, selected.sals);
  
    i = 0;
    while (i < selected.nelts)
--- 4586,4592 ----
    selected.sals = (struct symtab_and_line*) 
      xmalloc (sizeof (struct symtab_and_line) * selected.nelts);
    memset (selected.sals, 0, selected.nelts * sizeof (selected.sals[i]));
!   make_cleanup (xfree, selected.sals);
  
    i = 0;
    while (i < selected.nelts)
***************
*** 5065,5078 ****
        if (canonical != NULL) 
  	{
  	  *canonical = (char**) xmalloc (result.nelts * sizeof (char**));
! 	  make_cleanup (free, *canonical);
  	  for (k = 0; k < result.nelts; k += 1) 
  	    {
  	      (*canonical)[k] = 
  		extended_canonical_line_spec (result.sals[k], func_names[k]);
  	      if ((*canonical)[k] == NULL)
  		error ("Could not locate one or more breakpoints.");
! 	      make_cleanup (free, (*canonical)[k]);
  	    }
  	}
      }
--- 5065,5078 ----
        if (canonical != NULL) 
  	{
  	  *canonical = (char**) xmalloc (result.nelts * sizeof (char**));
! 	  make_cleanup (xfree, *canonical);
  	  for (k = 0; k < result.nelts; k += 1) 
  	    {
  	      (*canonical)[k] = 
  		extended_canonical_line_spec (result.sals[k], func_names[k]);
  	      if ((*canonical)[k] == NULL)
  		error ("Could not locate one or more breakpoints.");
! 	      make_cleanup (xfree, (*canonical)[k]);
  	    }
  	}
      }
***************
*** 5328,5334 ****
        arg = (char*) xmalloc (sizeof ("__gnat_raise_nodefer_with_msg if "
  				     "long_integer(e) = long_integer(&)")
  			     + toklen + 1);
!       make_cleanup (free, arg);
        if (toklen == 0)
  	strcpy (arg, "__gnat_raise_nodefer_with_msg");
        else if (STREQN (tok, "unhandled", toklen))
--- 5328,5334 ----
        arg = (char*) xmalloc (sizeof ("__gnat_raise_nodefer_with_msg if "
  				     "long_integer(e) = long_integer(&)")
  			     + toklen + 1);
!       make_cleanup (xfree, arg);
        if (toklen == 0)
  	strcpy (arg, "__gnat_raise_nodefer_with_msg");
        else if (STREQN (tok, "unhandled", toklen))
***************
*** 5354,5360 ****
        arg = (char*) 
  	xmalloc (sizeof ("system__assertions__raise_assert_failure")
  		 + strlen (tok) + 1);
!       make_cleanup (free, arg);
        sprintf (arg, "system__assertions__raise_assert_failure%s", tok);
      }
    */
--- 5354,5360 ----
        arg = (char*) 
  	xmalloc (sizeof ("system__assertions__raise_assert_failure")
  		 + strlen (tok) + 1);
!       make_cleanup (xfree, arg);
        sprintf (arg, "system__assertions__raise_assert_failure%s", tok);
      }
    */
Index: gdb/ada-tasks.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-tasks.c,v
retrieving revision 1.1
diff -c -3 -r1.1 ada-tasks.c
*** gdb/ada-tasks.c	4 Jun 2002 15:28:48 -0000	1.1
--- gdb/ada-tasks.c	13 Jul 2002 01:29:34 -0000
***************
*** 164,170 ****
    struct task_entry *pt;
  
    highest_task_num++;
!   new_task_entry = malloc (sizeof (struct task_entry));
    new_task_entry->task_num = highest_task_num;
    new_task_entry->task_id = p_task_id;
    new_task_entry->known_tasks_index = index;
--- 164,170 ----
    struct task_entry *pt;
  
    highest_task_num++;
!   new_task_entry = xmalloc (sizeof (struct task_entry));
    new_task_entry->task_num = highest_task_num;
    new_task_entry->task_id = p_task_id;
    new_task_entry->known_tasks_index = index;
***************
*** 236,242 ****
      {
        old_pt = pt;
        pt = pt->next_task;
!       free (old_pt);
      };
    task_list = NULL;
    highest_task_num = 0;
--- 236,242 ----
      {
        old_pt = pt;
        pt = pt->next_task;
!       xfree (old_pt);
      };
    task_list = NULL;
    highest_task_num = 0;


- Aidan
-- 
aidan@velvet.net  http://www.velvet.net/~aidan/  aim:aidans42
finger for pgp key fingerprint |- - - - - - - - - - - - - - -
01AA 1594 2DB0 09E3 B850       | Take down the Union Jack 
C2D0 9A2C 4CC9 3EC4 75E1       | it clashes with the sunset

Attachment: msg00291/pgp00000.pgp
Description: PGP signature


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