Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Eliminate quadratic slow-down on number of soilibs (part  	2).
Date: Mon, 18 May 2009 22:15:00 -0000	[thread overview]
Message-ID: <8ac60eac0905181515y13a9bfd8pa7d31f6a02dfae3@mail.gmail.com> (raw)
In-Reply-To: <m3ab5a3xvq.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

On Mon, May 18, 2009 at 2:27 PM, Tom Tromey <tromey@redhat.com> wrote:

> Paul> + {
> Paul> +   objc_csym = xmalloc (sizeof (*objc_csym));
> Paul> +   *objc_csym = objfile_csym;
> Paul> +   set_objfile_data (objfile, objc_objfile_data, objc_csym);
> Paul> + }
>
> [...]
>
> Paul> +void
> Paul> +_initialize_objc_lang (void)
> Paul> +{
> Paul> +  objc_objfile_data = register_objfile_data ();
> Paul> +}
>
> I think this should probably call register_objfile_data_with_cleanup,
> so that the per-objfile data can be freed when the objfile is
> destroyed.

I believe you are correct; I misread the objfile_free_data() code.

But isn't a better fix to just obstack_alloc the data instead of
xmalloc()ing it? Proposed patch attached. Tested on Linux/x86_64, no
regressions.

Thanks,
-- 
Paul Pluzhnikov

2009-05-18  Paul Pluzhnikov  <ppluzhnikov@google.com>

	    * objc-lang.c (find_methods): Plug a small memory leak.

[-- Attachment #2: objc-memleak.txt --]
[-- Type: text/plain, Size: 514 bytes --]

Index: src/gdb/objc-lang.c
===================================================================
--- src.orig/gdb/objc-lang.c	2009-05-18 15:01:25.000000000 -0700
+++ src/gdb/objc-lang.c	2009-05-18 14:53:58.000000000 -0700
@@ -1259,7 +1259,8 @@
 	}
       if (objc_csym == NULL)
 	{
-	  objc_csym = xmalloc (sizeof (*objc_csym));
+	  objc_csym = obstack_alloc (&objfile->objfile_obstack,
+				     sizeof (*objc_csym));
 	  *objc_csym = objfile_csym;
 	  set_objfile_data (objfile, objc_objfile_data, objc_csym);
 	}

  reply	other threads:[~2009-05-18 22:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01 22:17 Paul Pluzhnikov
2009-05-12  9:11 ` Joel Brobecker
2009-05-18 21:27 ` Tom Tromey
2009-05-18 22:15   ` Paul Pluzhnikov [this message]
2009-05-18 22:48     ` Tom Tromey
2009-05-18 22:58       ` Paul Pluzhnikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ac60eac0905181515y13a9bfd8pa7d31f6a02dfae3@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox