Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tclIO.c (CVS): Tcl_NextHashEntry should be used

Open1107673fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-01-23 07:24:08
tcl/generic/tclIO.c:

... static void DeleteChannelTable (clientData, interp):

   580      for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
   581              hPtr != (Tcl_HashEntry *) NULL;
   582              hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch)) {

        The second use of `Tcl_FirstHashEntry' seems to be a mistake.

... int Tcl_GetChannelNamesEx (interp, pattern):

  8752      for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch);
  8753              hPtr != (Tcl_HashEntry *) NULL;
  8754              hPtr = Tcl_NextHashEntry(&hSearch)) {
dkfplain2005-01-24 16:25:30
Logged In: YES 
user_id=79902

Noting that it is safe to do a loop{delete;next} - it is an
explicitly supported scenario.
andreas_kupriesplain2005-01-25 05:12:17
Logged In: YES 
user_id=75003

The code as is is OK. You get the first hash entry, delete,
and when we get the first entry again it will be a different
entry.

So it is not a bug per se.

I was not aware that the loop(delete,next) scenario is
supported. That could be a new thing. I dimly remember that
I changed code somewhere to the idiom as shown here because
the other failed.

Donal, note that according to annotate you were the last one
to touch this code, Nov 29 last year. There is however no
entry in the ChangeLog about this. ... Hm. Janitorial fixes
according to cvs log, rev 1.80.  But the CVS diff 1.79/1.80
does not show any difference at this location. Ok, something
is lying to me.

Still, this is not a bug. At most a minor style thing.
Log in (anonymous is fine) to add a comment.