   X11 - XDestroyImage problem
  Is there a way for XDestroyImage to free only the XImage structure but not the XImage->data pointer?edit: I tried setting the data to null before calling XDestroyImage and it seems to work, but is this a fluke?[edited by - ugenn on February 7, 2004 1:16:03 PM]
  If you didn''t allocate the memory yourself and you''re not told how to free it (because you''re not expected to or otherwise), it''s hackish to take over management of it yourself. Although it is a reasonably safe assumption that XFree would be the free function for any data allocated by Xlib...I could be wrong on this (having not done enough Xlib work): if you manage the XImage entirely on your own (using XInitImage rather than XCreateImage) you won''t have to free it with XDestroyImage and can treat its data however you''d like since you''re the one who allocated it before. Of course, you have to fill almost the whole XImage structure manually that way...   ;quote:Original post by Null and Void  If you didn''t allocate the memory yourself and you''re not told how to free it (because you''re not expected to or otherwise), it''s hackish to take over management of it yourself. Although it is a reasonably safe assumption that XFree would be the free function for any data allocated by Xlib...I could be wrong on this (having not done enough Xlib work): if you manage the XImage entirely on your own (using XInitImage rather than XCreateImage) you won''t have to free it with XDestroyImage and can treat its data however you''d like since you''re the one who allocated it before. Of course, you have to fill almost the whole   XImage structure manually that way...    I wasn''t specific enough in the original post. My XImage was created using XCreateImage and according to the XFree86 man pages, the XCreateImage function allocates the memory needed for an XImage structure for the specified display but does not allocate space for the image itself. Yet XDestroyImage frees the image buffer which seems like a very bad thing. 