This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [RFA 14/14] Changes to solib-svr4.c


>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:

Gary> +  if (so->lm_info)

For pointers now we write '!= NULL'.
There are several spots like this.

Gary> +	  /* If this library does not have a copy then create one.  */
Gary> +	  if (so->lm_info->copy == NULL)
Gary> +	    {
Gary> +	      struct so_list *copy;
Gary> +
Gary> +	      copy = XZALLOC (struct so_list);
Gary> +	      memcpy (copy, so, sizeof (struct so_list));

XZALLOC calls memset to clear the memory (that's what the "Z" means).
But you don't want that if you are just going to overwrite it.

I think XDUP would be better:

    copy = XDUP (struct so_list, so);

So many libiberty macros...

Gary> +	      copy->lm_info = xmalloc (sizeof (struct lm_info));
Gary> +	      memcpy (copy->lm_info, so->lm_info, sizeof (struct lm_info));

Ditto.

Tom


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