Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!elroy.jpl.nasa.gov!ncar!boulder!stan!garya!garya From: garya@garya.Solbourne.COM (Gary Aitken) Newsgroups: comp.windows.x Subject: XFreeColors bug Message-ID: <1990Nov30.205231.21765@Solbourne.COM> Date: 30 Nov 90 20:52:31 GMT Sender: news@Solbourne.COM Organization: Solbourne Computer, Inc. Lines: 51 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. ================================ cut here =================== /* * If: * A colormap is created and all cells are allocated in the create call * Then: * An attempt to free one of the allocated cells will fail. */ #include #include main (argc, argv) int argc ; char **argv ; { Display *dpy ; int screen; Window win ; XColor clr_def ; Colormap color_map ; Colormap def_color_map ; unsigned long pxl ; dpy = XOpenDisplay(0); screen = DefaultScreen(dpy); def_color_map = DefaultColormapOfScreen(ScreenOfDisplay(dpy,screen)) ; XSynchronize(dpy,1) ; win = XDefaultRootWindow(dpy) ; if (color_map = XCreateColormap(dpy, win, DefaultVisual(dpy,screen), AllocNone)) { XAllocColorCells(dpy, color_map, True, 0, 0, &pxl, 1); printf("allocated pixel: %d\n",pxl) ; pxl = 0 ; XFreeColors(dpy, color_map, &pxl, 1, 0) ; printf("Color cell allocated in user code free ok\n") ; } if (color_map = XCreateColormap(dpy, win, DefaultVisual(dpy,screen), AllocAll)) { pxl = 0 ; XFreeColors(dpy, color_map, &pxl, 1, 0) ; printf("Color cell allocated in Xlib free ok\n") ; } } -- Gary Aitken Solbourne Computer Inc. ARPA: garya@Solbourne.COM Longmont, CO UUCP: !{boulder,sun}!stan!garya