Hooks onto Xlib Data Structures

Various Xlib data structures have provisions for extension procedures to chain extension supplied data onto a list. These structures are GC, Visual, Screen, ScreenFormat, Display, and XFontStruct. Because the list pointer is always the first member in the structure, a single set of procedures can be used to manipulate the data on these lists.

The following structure is used in the functions in this section and is defined in X11/Xlib.h :

typedef struct _XExtData {
	int number;	/* number returned by XInitExtension */
	struct _XExtData *next;	/* next item on list of data for structure */
	int (*free_private)();	/* if defined,  called to free private */
	XPointer private_data;	/* data private to this extension. */
} XExtData;

.eM When any of the data structures listed above are freed, the list is walked, and the structure's free procedure (if any) is called. If free is NULL, then the library frees both the data pointed to by the private_data member and the structure itself.

union {	Display *display;
	GC gc;
	Visual *visual;
	Screen *screen;
	ScreenFormat *pixmap_format;
	XFontStruct *font } XEDataObject;

To get or attach data to a specified object, use XEHeadOfExtensionList().

To add data to an extension list, use XAddToExtensionList().

To find an object on an extension list, use XFindOnExtensionList().

The XAllocID() macro, which allocates and returns a resource ID, is defined in X11/Xlib.h .

The XAllocIDs() macro allocates and returns an array of resource ID.

Next: GC Caching

Christophe Tronche