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().
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'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().
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?
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).
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).
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?
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.
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.
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.
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.
I'd have to install valgrind first. Life's too short.
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.)
Muttley@dastardlyhq.com, dans le message <uisvvk$kdq5$1@dont-email.me>,
a écrit :
I'd have to install valgrind first. Life's too short.
Life's too short to debug WITHOUT valgrind.
On 11/14/23 10:12, Nicolas George wrote:
Muttley@dastardlyhq.com, dans le message <uisvvk$kdq5$1@dont-email.me>,
a écrit :
I'd have to install valgrind first. Life's too short.
Life's too short to debug WITHOUT valgrind.
And gdb is also pretty useful (if you compile with -ggdb).
On Wed, 15 Nov 2023 11:35:57 -0600
candycanearter07 <no@thanks.net> wrote:
On 11/14/23 10:12, Nicolas George wrote:
Muttley@dastardlyhq.com, dans le message <uisvvk$kdq5$1@dont-email.me>,
a écrit :
I'd have to install valgrind first. Life's too short.
Life's too short to debug WITHOUT valgrind.
And gdb is also pretty useful (if you compile with -ggdb).
-fsanitize=address is probably the most useful runtime debugging option in recent times IMO.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 360 |
Nodes: | 16 (2 / 14) |
Uptime: | 129:29:46 |
Calls: | 7,686 |
Files: | 12,828 |
Messages: | 5,711,157 |