Re: assertion error "PRI(owl) >= priority" otp.c line 248

Rhialto <[email protected]>
Newsgroups gmane.comp.window-managers.ctwm
Message-ID <[email protected]>
On Mon 08 Jul 2019 at 14:41:26 -0500, Matthew D. Fuller wrote:
> On Mon, Jul 08, 2019 at 11:08:25AM -0400 I heard the voice of
> Stefan Monnier, and lo! it spake thus:
> > > Actually, what we obviously need to do is get rid of TwmWindow
> > > structs wholesale, just embed SQLite, and store our runtime data
> > > there; then the indexes will find them for us!
> > 
> > I don't follow.  Wouldn't a hash-table work just as well?  SQLite
> > seems like a rather expensive way to implement a hash-table.
> 
> I mean, I'm actually assuming an _array_ would work better than
> either.  But if I can't dream up insane anti-solutions that would
> _technically_ work, what's the point of weekends anyway?

GetTwmWindow() uses XFindContext() to get our TwmWindow pointer from a
Window. That uses a hash table with a crappy hash function:

ctwm's win_utils.c:

    stat = XFindContext(dpy, w, TwmContext, (XPointer *)&twmwin);

where TwmContext is from

        // Allocate contexts/atoms/etc we use
        TwmContext = XUniqueContext();

libX11/dist/src/Context.c:

/* Given an XID and a context, returns a value between 0 and HashSize-1.
 *    Currently, this requires that HashSize be a power of 2.
 *    */

#define Hash(db,rid,context) \
    (db)->table[(((rid) << 1) + context) & (db)->mask]

/* Given an XID and context, returns the associated data.  Note that data
   here is a pointer since it is a return value.  Returns nonzero error code
   if an error has occured, 0 otherwise.  Possible errors are Entry-not-found.
*/

int XFindContext(Display *display, XID rid, XContext context, XPointer *data)
{
    register DB db;
    register TableEntry entry;

#ifdef MOTIFBC
    if (!display) db = NullDB; else
#endif
    {   
        LockDisplay(display);
        db = display->context_db;
        UnlockDisplay(display);
    }
    if (!db)
        return XCNOENT;
    _XLockMutex(&db->linfo);
    for (entry = Hash(db, rid, context); entry; entry = entry->next)
    {   
        if (entry->rid == rid && entry->context == context) {
            *data = (XPointer)entry->data;
            _XUnlockMutex(&db->linfo);
            return 0;
        }
    }
    _XUnlockMutex(&db->linfo);
    return XCNOENT;
}

Just fyi :-)

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl      -- if you're unable...to Speak." - Agent Elrond
signature.asc (application/pgp-signature, 455 B)
-----BEGIN PGP SIGNATURE-----

iQEcBAEBAgAGBQJdJNhzAAoJEJmJxkVhw/vTLMIIAKly7Bd3oT73AVfN+6C3MvZT
W0kT5Z2zn1M7mK4lZ5be4oS1Gmm+etxzHH2WoZCB0bcm0D7dgmMR3IbLr2AmcNFb
LkTpFJlS6lwZX5CuPCezc+EqsNORQVKniyI/z4cQXhBP7IgiZVT882IROyvM6Qz0
O8HEpEaI/aWAK7JXDqXRAsbKQl4hQquuhePhJMyMWHJ1zWVTSJibIHtpSU+fmAqD
U0ST75baWskaWjRtg/PFyZDjAYgxgIUKtGjgo/vlIeiz3+u3LPpOGDeR57ubq69m
VcUMka6FRcjaLvHQ2PTsYtWc2oDIPO7ygawMc11vU4ntCNrdeYeZ4gWojKkXATI=
=i7Nb
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.