[Rd] who frees dd and xd in X11_Open?

Prof Brian Ripley ripley@stats.ox.ac.uk
Thu, 15 Feb 2001 08:28:30 +0000 (GMT)


On 14 Feb 2001, Thomas Vogels wrote:

>
> Hi, I'm not sure this is a bug in the code, the comment or my
> thinking.  So first try goes to r-devel...  I find the following
> comment in X11_Open () (src/unix/X11/devX11.c):
>
> /* if we have to bail out with "error", then must free(dd) and free(xd) */
>
> A couple lines down, there is:
>
>     if (!strncmp(dsp, "png::", 5)) {
> 	FILE *fp;
> #ifndef HAVE_PNG
> 	error("No png support in this version of R");
> #endif
> 	if (!(fp = R_fopen(R_ExpandFileName(dsp+5), "w")))
> 	    error("could not open PNG file `%s'", dsp+6);
>     ...
>
> So what does the comment imply?  If error jumps out to the toplevel
> without giving X11DeviceDriver a chance to free dd and xd, then this
> should be:

[...]

Well, the thinking was that people would not be trying to use facilities
on systems where they had not bothered to implement them, so what problem
was a small memory leak?  They would only do it once, ever ....

In these cases it would be better to give a warning and return FALSE, when
the normal return mechanism will free xd and then dd.  I will alter it to
that when I have tested it out.

BDR

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._