Path: csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.unix.programmer,comp.windows.x Subject: Re: XDestroyImage() Date: Mon, 13 Nov 2023 11:35:27 -0800 Organization: None to speak of Lines: 53 Message-ID: <871qctfnuo.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="84428a78f4afd9e40bf8639aa2c3c323"; logging-data="922118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HXWdZmdTKXoKupIEwFg9N" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:C63SPCxJb/tDslPJgp9H7OokPrs= sha1:0MWEf/JTjE2obxXrcRpCQMjWUNg= Xref: csiph.com comp.unix.programmer:14547 comp.windows.x:458 Muttley@dastardlyhq.com writes: > On Sun, 12 Nov 2023 12:24:25 -0500 > James Kuyper wrote: >>In comp.unix.programmer Muttley@dastardlyhq.com wrote: >>> I'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 >>prominently: >> >>"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? > > Yes. All it says is: > > "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+u@gmail.com Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */