Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.windows.x > #447 > unrolled thread
| Started by | Muttley@dastardlyhq.com |
|---|---|
| First post | 2023-11-12 15:59 +0000 |
| Last post | 2023-11-13 15:57 +0000 |
| Articles | 13 — 8 participants |
Back to article view | Back to comp.windows.x
XDestroyImage() Muttley@dastardlyhq.com - 2023-11-12 15:59 +0000
Re: XDestroyImage() kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-11-12 16:20 +0000
Re: XDestroyImage() Muttley@dastardlyhq.com - 2023-11-12 16:30 +0000
Re: XDestroyImage() James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-11-12 12:24 -0500
Re: XDestroyImage() Muttley@dastardlyhq.com - 2023-11-13 11:05 +0000
Re: XDestroyImage() Winston <wbe@UBEBLOCK.psr.com.invalid> - 2023-11-13 11:53 -0500
Re: XDestroyImage() Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-11-13 11:35 -0800
Re: XDestroyImage() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-11-15 12:32 +0000
Re: XDestroyImage() scott@slp53.sl.home (Scott Lurndal) - 2023-11-12 17:34 +0000
Re: XDestroyImage() candycanearter07 <no@thanks.net> - 2023-11-12 19:11 -0600
Re: XDestroyImage() Muttley@dastardlyhq.com - 2023-11-13 11:06 +0000
Re: XDestroyImage() scott@slp53.sl.home (Scott Lurndal) - 2023-11-13 14:59 +0000
Re: XDestroyImage() Muttley@dastardlyhq.com - 2023-11-13 15:57 +0000
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2023-11-12 15:59 +0000 |
| Subject | XDestroyImage() |
| Message-ID | <uiqsp7$54ll$1@dont-email.me> |
Hello 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(). Anyone know? Thanks for any help
[toc] | [next] | [standalone]
| From | kalevi@kolttonen.fi (Kalevi Kolttonen) |
|---|---|
| Date | 2023-11-12 16:20 +0000 |
| Message-ID | <uiqtvp$5aof$1@dont-email.me> |
| In reply to | #447 |
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().
I just did the following on Fedora Linux 39:
dnf download --source libX11-devel
rpm2cpio libX11-1.8.7-1.fc39.src.rpm | cpio -idm
unxz libX11-1.8.7.tar.xz
tar xvf libX11-1.8.7.tar
and some quick grepping. Here are the relevant results:
int
XDestroyImage(
XImage *ximage)
{
return((*((ximage)->f.destroy_image))((ximage)));
}
image->f.destroy_image = _XDestroyImage;
static int _XDestroyImage (XImage *ximage)
{
Xfree(ximage->data);
Xfree(ximage->obdata);
Xfree(ximage);
return 1;
}
So yes, the user allocated data gets freed by
XDestroyImage().
br,
KK
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2023-11-12 16:30 +0000 |
| Message-ID | <uiquim$5dhn$1@dont-email.me> |
| In reply to | #448 |
On Sun, 12 Nov 2023 16:20:09 -0000 (UTC)
kalevi@kolttonen.fi (Kalevi Kolttonen) 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().
>
>I just did the following on Fedora Linux 39:
>
> dnf download --source libX11-devel
> rpm2cpio libX11-1.8.7-1.fc39.src.rpm | cpio -idm
> unxz libX11-1.8.7.tar.xz
> tar xvf libX11-1.8.7.tar
>
>and some quick grepping. Here are the relevant results:
>
>int
>XDestroyImage(
> XImage *ximage)
>{
> return((*((ximage)->f.destroy_image))((ximage)));
>}
>
>
>image->f.destroy_image = _XDestroyImage;
>
>
>static int _XDestroyImage (XImage *ximage)
>{
> Xfree(ximage->data);
> Xfree(ximage->obdata);
> Xfree(ximage);
> return 1;
>}
>
>So yes, the user allocated data gets freed by
>XDestroyImage().
Thanks. Seems a bit inconsistent that XCreateImage() can't allocate but then
thats Xlib for you.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2023-11-12 12:24 -0500 |
| Message-ID | <uir1o9$5nkq$1@dont-email.me> |
| In reply to | #447 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2023-11-13 11:05 +0000 |
| Message-ID | <uisvuj$kdn3$1@dont-email.me> |
| In reply to | #450 |
On Sun, 12 Nov 2023 12:24:25 -0500 James Kuyper <jameskuyper@alumni.caltech.edu> 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.
[toc] | [prev] | [next] | [standalone]
| From | Winston <wbe@UBEBLOCK.psr.com.invalid> |
|---|---|
| Date | 2023-11-13 11:53 -0500 |
| Message-ID | <ydh6lpegrh.fsf@UBEblock.psr.com> |
| In reply to | #453 |
Muttley@dastardlyhq.com writes:
> On Sun, 12 Nov 2023 12:24:25 -0500
> James Kuyper <jameskuyper@alumni.caltech.edu> 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.
Check your man page again. Yes, the description of XDestroyImage just
before SEE ALSO says only what you quoted, but, on my libX11 1.8.7
version of the man page, the paragraph James quoted ("Note that ...") is
above, at the 5th paragraph, right after the XCreateImage paragraph.
-WBE
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-11-13 11:35 -0800 |
| Message-ID | <871qctfnuo.fsf@nosuchdomain.example.com> |
| In reply to | #453 |
Muttley@dastardlyhq.com writes:
> On Sun, 12 Nov 2023 12:24:25 -0500
> James Kuyper <jameskuyper@alumni.caltech.edu> 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 */
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2023-11-15 12:32 +0000 |
| Message-ID | <87bkbvkxi6.fsf@bsb.me.uk> |
| In reply to | #458 |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Muttley@dastardlyhq.com writes:
>> On Sun, 12 Nov 2023 12:24:25 -0500
>> James Kuyper <jameskuyper@alumni.caltech.edu> 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.)
Just as a random data point, on a Mac I have access to (but don't
understand well enough to say anything reliable about what software it
has installed) I get this:
$ man XDestroyImage | wc -l
140
$ man XDestroyImage | tail -n 1
X Version 11 libX11 1.5.0 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.
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2023-11-12 17:34 +0000 |
| Message-ID | <K084N.102$ayBd.16@fx07.iad> |
| In reply to | #447 |
Muttley@dastardlyhq.com writes: >Hello > >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(). > >Anyone know? Kalevi answered. To obtain an answer this question you could have run the application under valgrind - it would tell you about any memory that hadn't been deallocated at exit (using the leak check option).
[toc] | [prev] | [next] | [standalone]
| From | candycanearter07 <no@thanks.net> |
|---|---|
| Date | 2023-11-12 19:11 -0600 |
| Message-ID | <uirt4o$7n1l$6@dont-email.me> |
| In reply to | #451 |
On 11/12/23 11:34, Scott Lurndal wrote: > Muttley@dastardlyhq.com writes: >> Hello >> >> 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(). >> >> Anyone know? > > Kalevi answered. > > To obtain an answer this question you could have run the application under > valgrind - it would tell you about any memory that hadn't been > deallocated at exit (using the leak check option). > Or, you could set the user memory to a stack variable and see what happens. -- user <candycane> is generated from /dev/urandom
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2023-11-13 11:06 +0000 |
| Message-ID | <uisvvk$kdq5$1@dont-email.me> |
| In reply to | #451 |
On Sun, 12 Nov 2023 17:34:34 GMT scott@slp53.sl.home (Scott Lurndal) wrote: >Muttley@dastardlyhq.com writes: >>Hello >> >>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(). >> >>Anyone know? > >Kalevi answered. > >To obtain an answer this question you could have run the application under >valgrind - it would tell you about any memory that hadn't been >deallocated at exit (using the leak check option). I'd have to install valgrind first. Life's too short.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2023-11-13 14:59 +0000 |
| Message-ID | <eRq4N.33004$BbXa.15497@fx16.iad> |
| In reply to | #454 |
Muttley@dastardlyhq.com writes: >On Sun, 12 Nov 2023 17:34:34 GMT >scott@slp53.sl.home (Scott Lurndal) wrote: >>Muttley@dastardlyhq.com writes: >>>Hello >>> >>>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(). >>> >>>Anyone know? >> >>Kalevi answered. >> >>To obtain an answer this question you could have run the application under >>valgrind - it would tell you about any memory that hadn't been >>deallocated at exit (using the leak check option). > >I'd have to install valgrind first. Life's too short. > sudo apt -y install valgrind yum install valgrind not too short for that.
[toc] | [prev] | [next] | [standalone]
| From | Muttley@dastardlyhq.com |
|---|---|
| Date | 2023-11-13 15:57 +0000 |
| Message-ID | <uith0j$n6fr$1@dont-email.me> |
| In reply to | #455 |
On Mon, 13 Nov 2023 14:59:22 GMT scott@slp53.sl.home (Scott Lurndal) wrote: >Muttley@dastardlyhq.com writes: >>On Sun, 12 Nov 2023 17:34:34 GMT >>scott@slp53.sl.home (Scott Lurndal) wrote: >>>Muttley@dastardlyhq.com writes: >>>>Hello >>>> >>>>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(). >>>> >>>>Anyone know? >>> >>>Kalevi answered. >>> >>>To obtain an answer this question you could have run the application under >>>valgrind - it would tell you about any memory that hadn't been >>>deallocated at exit (using the leak check option). >> >>I'd have to install valgrind first. Life's too short. >> > >sudo apt -y install valgrind >yum install valgrind > >not too short for that. fenris$ yum -bash: yum: command not found Its a Mac so I'd probably have to piss about with Brew. Like I said, lifes too short.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.windows.x
csiph-web