[RFA] xfree() replacements for free() in gdb

Kevin Buettner kevinb@cygnus.com
Thu Jan 25 16:42:00 GMT 2001


On Jan 25,  4:47pm, John R. Moore wrote:

> 2001-01-25  John R. Moore  <jmoore@cygnus.com>
> 
>         * cli/cli-cmds.c (apropos_command): Changed free() to xfree() where 
  ^^^^^^^^
Use a tab here.

> 	appropriate. Also changed Copyright to include 2001.
                    ^
Also, you need two spaces between the period and the start of the next
sentence.

> 	* gdbarch.sh (gdbarch_free): Likewise.
> 	* remote-utils.h (sr_set_device): Likewise.
> 	* symtab.h (obstack_chunk_free, SYMBOL_INIT_DEMANGLED_NAME): Likewise.
> 	* value.h (value_free): Likewise.
> 	* gdbarch.c: Regenerated.
> 	* gdbarch.h: Regenerated.

A minor point, but I would've grouped the changes for gdbarch.sh,
gdbarch.c, and gdbarch.h together as follows:

	...
	* value.h (value_free): Likewise.
	* gdbarch.sh (gdbarch_free): Likewise.
	* gdbarch.c, gdbarch.h: Regenerated.

[...]

I'm puzzled about how you managed to regenerate gdbarch.h out of
gdbarch.sh.  (Look at the copyright notices.  It looks like you got
it right in gdbarch.sh, but it doesn't appear to me that the gdbarch.h
copyright notice matches your fixes in gdbarch.sh...

> Index: gdbarch.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.h,v
> retrieving revision 1.40
> diff -p -u -w -r1.40 gdbarch.h
> --- gdbarch.h	2001/01/22 23:32:49	1.40
> +++ gdbarch.h	2001/01/25 22:11:58
> @@ -1,7 +1,7 @@
>  /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
>  
>  /* Dynamic architecture support for GDB, the GNU debugger.
> -   Copyright 1998-1999, Free Software Foundation, Inc.
> +   Copyright 1998-2001, Free Software Foundation, Inc.
>  
>     This file is part of GDB.
>  
> Index: gdbarch.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.sh,v
> retrieving revision 1.51
> diff -p -u -w -r1.51 gdbarch.sh
> --- gdbarch.sh	2001/01/22 23:32:49	1.51
> +++ gdbarch.sh	2001/01/25 22:11:25
> @@ -1,7 +1,7 @@
>  #!/bin/sh -u
>  
>  # Architecture commands for GDB, the GNU debugger.
> -# Copyright 1998-2000 Free Software Foundation, Inc.
> +# Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
>  #
>  # This file is part of GDB.
>  #
> @@ -531,7 +531,7 @@ cat <<EOF
>  /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
>  
>  /* Dynamic architecture support for GDB, the GNU debugger.
> -   Copyright 1998-1999, Free Software Foundation, Inc.
> +   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
>  
>     This file is part of GDB.
>  
> @@ -1239,7 +1239,7 @@ void
>  gdbarch_free (struct gdbarch *arch)
>  {
>    /* At the moment, this is trivial.  */
> -  free (arch);
> +  xfree (arch);
>  }
>  EOF

> Index: value.h
[...]
> -#define value_free(val) free ((PTR)val)
> +#define value_free(val) xfree ((PTR)val)

I think I commented on this one before...  I am against the (PTR)
coercion being here.  Since xfree() takes a void *, it should not
be necessary to coerce pointer values being passed to it.  OTOH,
if xfree is (inadvertently or otherwise) used on an int or a long,
the above define will mask a real problem that ought to be fixed
in some other fashion.


More information about the Gdb-patches mailing list