Mercurial > octave
diff src/DLD-FUNCTIONS/convhulln.cc @ 14339:3e4350f09a55 stable
close temporary files opened for Qhull
* __delaunay__.cc (close_fcn): New static function.
(F__delaunay__): Add close_fcn and outfile to unwind protect stack.
* __voronoi__.cc (close_fcn): New static function.
(F__voronoi__): Add close_fcn and outfile to unwind protect stack.
* convhull.cc (close_fcn): New static function.
(Fconvhull): Add close_fcn and outfile to unwind protect stack.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Feb 2012 15:54:10 -0500 |
parents | decea31ea010 |
children | 9b23169e2712 065bc7944335 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/convhulln.cc Mon Feb 06 15:27:00 2012 -0500 +++ b/src/DLD-FUNCTIONS/convhulln.cc Mon Feb 06 15:54:10 2012 -0500 @@ -40,6 +40,7 @@ #include "error.h" #include "oct-obj.h" #include "parse.h" +#include "unwind-prot.h" #if defined (HAVE_QHULL) # include "oct-qhull.h" @@ -48,6 +49,12 @@ # endif #endif +static void +close_fcn (FILE *f) +{ + gnulib::fclose (f); +} + DEFUN_DLD (convhulln, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{h} =} convhulln (@var{pts})\n\ @@ -128,6 +135,8 @@ boolT ismalloc = false; + unwind_protect frame; + // Replace the outfile pointer with stdout for debugging information. #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) FILE *outfile = gnulib::fopen ("NUL", "w"); @@ -135,10 +144,12 @@ FILE *outfile = gnulib::fopen ("/dev/null", "w"); #endif FILE *errfile = stderr; - - if (! outfile) + + if (outfile) + frame.add_fcn (close_fcn, outfile); + else { - error ("convhulln: Unable to create temporary file for output."); + error ("convhulln: unable to create temporary file for output"); return retval; }