public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Do not call xmalloc_failed in expandargv
@ 2005-09-27 14:51 Mark Mitchell
  2005-09-27 15:17 ` Ian Lance Taylor
  2005-09-27 15:40 ` DJ Delorie
  0 siblings, 2 replies; 8+ messages in thread
From: Mark Mitchell @ 2005-09-27 14:51 UTC (permalink / raw)
  To: gdb, gdb-patches; +Cc: ian, dj


This patch fixes the link error when compiling GDB.  The cause of the
failure is that GDB's utils.c defines xmalloc, but not xmalloc_failed;
therefore, expandargv pulls in xmalloc.c to get xmalloc_failed, which
causes a duplicate symbol error for xmalloc.  Arguably, GDB should
define xmalloc_failed, so as to completely replace the interface.  (In
fact, GDB provides "nomem", which has almost the same signature.)
However, this patch to libiberty will be more robust if there are
other similar programs out there that, like GDB, replace only some of
the interface.  We could also split xmalloc_failed into its own file,
so as to decouple it from xmalloc.

In any case, is this patch OK, to get GDB back to linking?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-09-27  Mark Mitchell  <mark@codesourcery.com>

	* argv.c (expandargv): Do not use xmalloc_failed.

Index: argv.c
===================================================================
RCS file: /cvs/src/src/libiberty/argv.c,v
retrieving revision 1.14
diff -c -5 -p -r1.14 argv.c
*** argv.c	26 Sep 2005 21:02:59 -0000	1.14
--- argv.c	27 Sep 2005 14:45:31 -0000
*************** expandargv (argcp, argvp)
*** 363,375 ****
        /* If *ARGVP is not already dynamically allocated, copy it.  */
        if (!argv_dynamic)
  	{
  	  *argvp = dupargv (*argvp);
  	  if (!*argvp)
! 	    /* We do not know exactly many bytes dupargv tried to
! 	       allocate, so make a guess.  */
! 	    xmalloc_failed (*argcp * 32);
  	}
        /* Count the number of arguments.  */
        file_argc = 0;
        while (file_argv[file_argc] && *file_argv[file_argc])
  	++file_argc;
--- 363,376 ----
        /* If *ARGVP is not already dynamically allocated, copy it.  */
        if (!argv_dynamic)
  	{
  	  *argvp = dupargv (*argvp);
  	  if (!*argvp)
! 	    {
! 	      fprintf (stderr, "\n%sout of memory\n");
! 	      xexit (1);
! 	    }
  	}
        /* Count the number of arguments.  */
        file_argc = 0;
        while (file_argv[file_argc] && *file_argv[file_argc])
  	++file_argc;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-27 18:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-27 14:51 PATCH: Do not call xmalloc_failed in expandargv Mark Mitchell
2005-09-27 15:17 ` Ian Lance Taylor
2005-09-27 15:22   ` Mark Mitchell
2005-09-27 15:40 ` DJ Delorie
2005-09-27 15:46   ` Mark Mitchell
2005-09-27 18:04     ` DJ Delorie
2005-09-27 18:33       ` Mark Mitchell
2005-09-27 18:35         ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).