Tk Library Source Code

View Ticket
Login
Ticket UUID: 842408
Title: pool.tcl - requesting an allocated item returns error
Type: Bug Version: None
Submitter: eriklns Created on: 2003-11-14 21:22:40
Subsystem: struct Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2003-11-19 13:40:18
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2003-11-19 06:40:18
Description:
Observed:
=======

package require struct
struct::pool::pool chars
chars add a
chars add b
chars add c
chars request char -prefer a
chars request char -prefer a

The last command fails, returning an error.

Desired
=====
The last command should return the value zero, as
documented.

Fix
===
A bug in the code for ::struct::pool::request was the
cause.
I fixed the code, and attached a diff (with respect to
version 1.2 of pool.tcl) which has that fix.

Greetings,

Erik Leunissen
==========
User Comments: andreas_kupries added on 2003-11-19 13:40:18:
Logged In: YES 
user_id=75003

Accepted alternative fix and commited to head.

nobody added on 2003-11-19 10:26:44:
Logged In: NO 

I also encountered this issue, but fixed it slightly
differently. Note that this error occurs only when there are
unallocated items in the pool.

Alternative diff:

--- pool.tcl.orig       Wed Nov 19 03:19:50 2003
+++ pool.tcl    Wed Nov 19 03:02:54 2003
@@ -675,6 +675,8 @@
             if { $state($prefer) == -1 } {
                 set index [lsearch $pool(freeitems) $prefer]
                 set item $prefer
+            } else {
+                return 0
             }
         } else  {
             set index 0

eriklns added on 2003-11-15 04:22:40:

File Added - 67531: diff.txt

Attachments: