[comp.windows.x] XAllocColor/XFreeColors question

bradley@grip.cis.upenn.edu (John Bradley) (10/19/90)

Situation:  I allocate two read-only color cells.  Because the colors were
exactly the same, (or because the colors were different, but the *displayable*
colors were the same (happens all the time on machines with 4-bit RGB D/As)),
I've actually allocated the same color cell twice.  In and of itself, not
a problem.

However, when I want to free the color cells, I have a bit of a problem.  On
certain MIT X11R4 servers, I've seen that color cells are not released unless
they are freed the same number of times that they were allocated, even if
the multiple allocations were all from one client.  This seems like perfectly
reasonable behavior, and I can live with it.

Unfortunately, OTHER X servers (IBM 6000/AIX 3.1, and others) get all bent-
out-of-shape if I try to free the same color cell more than once.

Question:  Which behavior is 'correct'?  The Xlib manual doesn't really seem
to say what should happen.  

--jhb

klee@wsl.dec.com (Ken Lee) (10/20/90)

In article <31383@netnews.upenn.edu>, bradley@grip.cis.upenn.edu (John Bradley) writes:
|> However, when I want to free the color cells, I have a bit of a problem.  On
|> certain MIT X11R4 servers, I've seen that color cells are not released unless
|> they are freed the same number of times that they were allocated, even if
|> the multiple allocations were all from one client.  This seems like perfectly
|> reasonable behavior, and I can live with it.
|> 
|> Unfortunately, OTHER X servers (IBM 6000/AIX 3.1, and others) get all bent-
|> out-of-shape if I try to free the same color cell more than once.

This sentence appears in the X11R4 protocol spec:

"A read-only entry is not actually freed until it has been freed by all
clients, and if a client allocates the same read-only entry multiple
times, it must free the entry that many times before the entry is
actually freed."

The sentence did not appear in the X11R3 spec, so older servers may
behave differently.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

dwig@b11.ingr.com (David Wiggins) (10/20/90)

bradley@grip.cis.upenn.edu (John Bradley) writes:

>Situation:  I allocate two read-only color cells.  Because the colors were
>exactly the same, (or because the colors were different, but the *displayable*
>colors were the same (happens all the time on machines with 4-bit RGB D/As)),
>I've actually allocated the same color cell twice.  In and of itself, not
>a problem.

>However, when I want to free the color cells, I have a bit of a problem.  On
>certain MIT X11R4 servers, I've seen that color cells are not released unless
>they are freed the same number of times that they were allocated, even if
>the multiple allocations were all from one client.  This seems like perfectly
>reasonable behavior, and I can live with it.

>Unfortunately, OTHER X servers (IBM 6000/AIX 3.1, and others) get all bent-
>out-of-shape if I try to free the same color cell more than once.

>Question:  Which behavior is 'correct'?  The Xlib manual doesn't really seem
>to say what should happen.  

>--jhb

Cut-n-pasted directly from the protocol document:

FreeColors

     ...a read-only entry is not actually freed until it
     has been freed by all clients, and if a client allo-
     cates the same read-only entry multiple times, it must
     free the entry that many times before the entry is
     actually freed.

David P. Wiggins	dwig@ingr.com  or  uunet!ingr!dwig	(205)730-6365
Intergraph Corporation, One Madison Industrial Park, Huntsville, AL 35807