Post by M***@dastardlyhq.comOn Sun, 12 Nov 2023 12:24:25 -0500
Post by James KuyperPost by M***@dastardlyhq.comI'm a bit uncertain from the man page and from googling around whether
XDestroyImage() only frees the XImage structure created by XCreateImage()
or whether it also frees the user allocated memory that gets passed into
XCreateImage().
The man page that I found describing the XDestroyImage macro says, quite
"Note that when the image is created using XCreateImage(), XGetImage(),
or XSubImage(), the destroy procedure that this macro calls frees both
the image structure and the data pointed to by the image structure."
Does the manpage you viewed lack that statement?
"The XDestroyImage function deallocates the memory associated with the
XImage structure."
Which is ambiguous.
That's very surprising. Looking at a Git mirror of libX11
(https://github.com/mirror/libX11), that "Note that" paragraph appears
in every version of that man page going back to 2003 (X11R6.6).
On my system, Ubuntu 22.04, I get:
$ man XDestroyImage | wc -l
139
$ man XDestroyImage | tail -n 1
X Version 11 libX11 1.7.5 XCreateImage(3)
$ man XDestroyImage | sed -n '/Note that/,+3p'
Note that when the image is created using XCreateImage, XGetImage, or
XSubImage, the destroy procedure that the XDestroyImage function calls
frees both the image structure and the data pointed to by the image
structure.
$
What do you get on your system? (You mentioned that you're on a Mac.)
See also https://linux.die.net/man/3/xdestroyimage
(Note that the XDestroyImage man page is typically a symlink to the
XInitImage man page.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+***@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */