Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!snorkelwacker.mit.edu!bloom-beacon!LIGHTNING.MCRCIM.MCGILL.EDU!mouse From: mouse@LIGHTNING.MCRCIM.MCGILL.EDU Newsgroups: comp.windows.x Subject: Re: XFreeColors bug Message-ID: <9012010716.AA00341@lightning.McRCIM.McGill.EDU> Date: 1 Dec 90 07:16:20 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 36 > The following program demonstrates an XFreeColors Bug in the X11R4 > library. If one creates a private colormap and allocates cells in it > via the create call, those cells cannot be freed. However, if the > cells are not allocated during the create, but are instead > specifically allocated later, they can be freed. [edited down -dM] > if (color_map = XCreateColormap(dpy, win, DefaultVisual(dpy,screen), AllocNone)) { > XAllocColorCells(dpy, color_map, True, 0, 0, &pxl, 1); > XFreeColors(dpy, color_map, &pxl, 1, 0) ; > } > if (color_map = XCreateColormap(dpy, win, DefaultVisual(dpy,screen), AllocAll)) { > pxl = 0 ; > XFreeColors(dpy, color_map, &pxl, 1, 0) ; > } This is not a bug. From the Xlib documentation: To create a colormap for a screen, use XCreateColormap. Colormap XCreateColormap(display, w, visual, alloc) [...] alloc Specifies the colormap entries to be allocated. You can pass AllocNone or AllocAll. [...] If alloc is AllocAll, the entire colormap is allocated writable. The initial values of all allocated entries are undefined. For GrayScale and PseudoColor, the effect is as if [...]. For DirectColor, the effect is as if [...]. However, in all cases, none of these entries can be freed by using XFreeColors. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu