From: Daniel Jacobowitz <drow@mvista.com>
To: Syd Polk <spolk@apple.com>
Cc: gdb-patches@sources.redhat.com, insight@sources.redhat.com,
keiths@cygnus.com, Elena Zannoni <ezannoni@cygnus.com>
Subject: Re: [RFA] Sorting symbols. Again.
Date: Wed, 30 Jan 2002 14:37:00 -0000 [thread overview]
Message-ID: <20020130173735.A9126@nevyn.them.org> (raw)
In-Reply-To: <DE5AE60F-15CC-11D6-99A6-0050E4C09301@apple.com>
On Wed, Jan 30, 2002 at 02:01:10PM -0800, Syd Polk wrote:
>
> Where is sort_funcVals called from? It it called pretty close to the Tcl
> layer? If so, you might want to use "lsort -command foo" from the tcl
> level and implement the comparison command in C. Given that the sort
> command you are using pares down to a simple strcmp, this would be much
> cleaner than doing what you are doing.
It's called from gdb_listfuncs. Are the TCL functions exported by
insight generally available to some kind of user scripts, or can I
change callers?
In fact, I see that one of the two callers already sorts the list
itself.
> You should not have to loop through the objects in list_objv to Incr or
> Decr their refCounts. Tcl_SetListObj does that automatically. They are
> created with a refCount of 0; Tcl_SetListObj incrs them to 1. What you
> are doing is creating them, setting them to 1, calling Tcl_SetListObj
> (which incrs them to 2), and the decrementing them back to 1.
>
> Also, it is really, really slimy to create Tcl_Objs without going
> through Tcl_New*Obj.
>
> I would much prefer that you duplicate the list, and then call "lsort".
> Pseudo-code:
>
> Tcl_Obj *commandArray[2];
>
> Tcl_ListObjGetElements (NULL, result_ptr->obj_ptr, &list_objc,
> &list_objv);
> newList = Tcl_NewListObj(list_objc, list_objv);
> commandArray[1] = newList;
> Tcl_IncrRefCount(newList);
> commandArray[0] = Tcl_NewObjFromString("lsort");
> Tcl_IncrRefCount(commandArray[0]);
> result = Tcl_EvalObjv(interp, 2, commandArray);
> Tcl_DecrRefCount(commandArray[0]);
>
> /* newList now has sorted list. */
>
> I am not a maintainer, but I worked in the core of Tcl for a couple of
> years for John O., and doing block allocates of Tcl_Objs is just asking
> for trouble, and will lead to problems if insight is ever compiled to
> TCL_MEM_DEBUG, or other things.
I don't think I did anything of the sort; but perhaps I misunderstood
Tcl_SetListObj. The documentation doesn't say anything about how to
allocate the objv. The refcount mess was because of using SetListObj,
but I suppose I understand now that creating a new object and then
destroying the old one would have worked out cleaner. Hopefully the
above will be accepted and I can delete the sort entirely :)
Thanks for the helpful comments.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2002-01-30 22:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-29 21:54 Daniel Jacobowitz
2002-01-30 14:01 ` Syd Polk
2002-01-30 14:37 ` Daniel Jacobowitz [this message]
2002-01-30 14:53 ` Syd Polk
2002-01-30 20:54 ` Daniel Jacobowitz
2002-01-31 10:19 ` Syd Polk
2002-02-10 19:17 ` Elena Zannoni
2002-02-10 19:22 ` Daniel Jacobowitz
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=20020130173735.A9126@nevyn.them.org \
--to=drow@mvista.com \
--cc=ezannoni@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
--cc=insight@sources.redhat.com \
--cc=keiths@cygnus.com \
--cc=spolk@apple.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