Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* question, xmalloc and gdbserver?
@ 2011-03-01 23:25 Michael Snyder
  2011-03-02  9:40 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2011-03-01 23:25 UTC (permalink / raw)
  To: gdb

What's the policy about using malloc vs. xmalloc in gdbserver?
I notice both are used, with xmalloc being favored, but there are
still quite a few calls to malloc.


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

* Re: question, xmalloc and gdbserver?
  2011-03-01 23:25 question, xmalloc and gdbserver? Michael Snyder
@ 2011-03-02  9:40 ` Pedro Alves
  2011-03-02 18:31   ` Michael Snyder
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2011-03-02  9:40 UTC (permalink / raw)
  To: gdb; +Cc: Michael Snyder

On Tuesday 01 March 2011 23:25:27, Michael Snyder wrote:
> What's the policy about using malloc vs. xmalloc in gdbserver?
> I notice both are used, with xmalloc being favored, but there are
> still quite a few calls to malloc.

I think malloc is used when a failure is not to be considered
fatal, e.g., when the size of the data is determined by the input.

Doug went through and fixed a bunch a while ago (yearly 2009).
You should be able to find the discussions around the patches
in the archives.  Basically, if there's no explicit check
for NULL after malloc, then it's quite likely a new call
that went in after Doug's fixes.

-- 
Pedro Alves


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

* Re: question, xmalloc and gdbserver?
  2011-03-02  9:40 ` Pedro Alves
@ 2011-03-02 18:31   ` Michael Snyder
  2011-03-02 18:45     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2011-03-02 18:31 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Pedro Alves wrote:
> On Tuesday 01 March 2011 23:25:27, Michael Snyder wrote:
>> What's the policy about using malloc vs. xmalloc in gdbserver?
>> I notice both are used, with xmalloc being favored, but there are
>> still quite a few calls to malloc.
> 
> I think malloc is used when a failure is not to be considered
> fatal, e.g., when the size of the data is determined by the input.
> 
> Doug went through and fixed a bunch a while ago (yearly 2009).
> You should be able to find the discussions around the patches
> in the archives.  Basically, if there's no explicit check
> for NULL after malloc, then it's quite likely a new call
> that went in after Doug's fixes.
> 

OK, so you're saying that all "legitimate" calls to malloc
will be checked?



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

* Re: question, xmalloc and gdbserver?
  2011-03-02 18:31   ` Michael Snyder
@ 2011-03-02 18:45     ` Pedro Alves
  2011-03-02 19:41       ` Michael Snyder
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2011-03-02 18:45 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

On Wednesday 02 March 2011 18:31:28, Michael Snyder wrote:
> OK, so you're saying that all "legitimate" calls to malloc
> will be checked?

Yes.

-- 
Pedro Alves


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

* Re: question, xmalloc and gdbserver?
  2011-03-02 18:45     ` Pedro Alves
@ 2011-03-02 19:41       ` Michael Snyder
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2011-03-02 19:41 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Pedro Alves wrote:
> On Wednesday 02 March 2011 18:31:28, Michael Snyder wrote:
>> OK, so you're saying that all "legitimate" calls to malloc
>> will be checked?
> 
> Yes.
> 

Well, here's the one I'm thinking of.  It's not clear to me
what to do in case of error.  What do you think?

/* Put a stop reply to the stop reply queue.  */

static void
queue_stop_reply (ptid_t ptid, struct target_waitstatus *status)
{
   struct vstop_notif *new_notif;

   new_notif = malloc (sizeof (*new_notif));
   new_notif->next = NULL;
   new_notif->ptid = ptid;
   new_notif->status = *status;

[...]



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

end of thread, other threads:[~2011-03-02 19:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-01 23:25 question, xmalloc and gdbserver? Michael Snyder
2011-03-02  9:40 ` Pedro Alves
2011-03-02 18:31   ` Michael Snyder
2011-03-02 18:45     ` Pedro Alves
2011-03-02 19:41       ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox