Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/__voronoi__.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 | 824e5d362aba |
children | 60e5cf354d80 |
comparison
equal
deleted
inserted
replaced
14338:1ecfba4427ff | 14339:3e4350f09a55 |
---|---|
42 | 42 |
43 #include "Cell.h" | 43 #include "Cell.h" |
44 #include "defun-dld.h" | 44 #include "defun-dld.h" |
45 #include "error.h" | 45 #include "error.h" |
46 #include "oct-obj.h" | 46 #include "oct-obj.h" |
47 #include "unwind-prot.h" | |
47 | 48 |
48 #if defined (HAVE_QHULL) | 49 #if defined (HAVE_QHULL) |
49 # include "oct-qhull.h" | 50 # include "oct-qhull.h" |
50 # if defined (NEED_QHULL_VERSION) | 51 # if defined (NEED_QHULL_VERSION) |
51 char qh_version[] = "__voronoi__.oct 2007-07-24"; | 52 char qh_version[] = "__voronoi__.oct 2007-07-24"; |
52 # endif | 53 # endif |
53 #endif | 54 #endif |
55 | |
56 static void | |
57 close_fcn (FILE *f) | |
58 { | |
59 gnulib::fclose (f); | |
60 } | |
54 | 61 |
55 DEFUN_DLD (__voronoi__, args, , | 62 DEFUN_DLD (__voronoi__, args, , |
56 "-*- texinfo -*-\n\ | 63 "-*- texinfo -*-\n\ |
57 @deftypefn {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts})\n\ | 64 @deftypefn {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts})\n\ |
58 @deftypefnx {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts}, @var{options})\n\ | 65 @deftypefnx {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts}, @var{options})\n\ |
113 } | 120 } |
114 } | 121 } |
115 | 122 |
116 boolT ismalloc = false; | 123 boolT ismalloc = false; |
117 | 124 |
125 unwind_protect frame; | |
126 | |
118 // Replace the outfile pointer with stdout for debugging information. | 127 // Replace the outfile pointer with stdout for debugging information. |
119 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) | 128 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) |
120 FILE *outfile = gnulib::fopen ("NUL", "w"); | 129 FILE *outfile = gnulib::fopen ("NUL", "w"); |
121 #else | 130 #else |
122 FILE *outfile = gnulib::fopen ("/dev/null", "w"); | 131 FILE *outfile = gnulib::fopen ("/dev/null", "w"); |
123 #endif | 132 #endif |
124 FILE *errfile = stderr; | 133 FILE *errfile = stderr; |
125 | 134 |
126 if (! outfile) | 135 if (outfile) |
136 frame.add_fcn (close_fcn, outfile); | |
137 else | |
127 { | 138 { |
128 error ("__voronoi__: Unable to create temporary file for output."); | 139 error ("__voronoi__: unable to create temporary file for output"); |
129 return retval; | 140 return retval; |
130 } | 141 } |
131 | 142 |
132 // qh_new_qhull command and points arguments are not const... | 143 // qh_new_qhull command and points arguments are not const... |
133 | 144 |