usermem_r-cpp.cpp
Go to the documentation of this file.
1 /*<html><pre> -<a href="qh-user_r.htm"
2  >-------------------------------</a><a name="TOP">-</a>
3 
4  usermem_r-cpp.cpp
5 
6  Redefine qh_exit() as 'throw std::runtime_error("QH10003 ...")'
7 
8  This file is not included in the Qhull builds.
9 
10  qhull_r calls qh_exit() when qh_errexit() is not available. For example,
11  it calls qh_exit() if you linked the wrong qhull library.
12 
13  The C++ interface avoids most of the calls to qh_exit().
14 
15  If needed, include usermem_r-cpp.o before libqhullstatic_r.a. You may need to
16  override duplicate symbol errors (e.g. /FORCE:MULTIPLE for DevStudio). It
17  may produce a warning about throwing an error from C code.
18 */
19 
20 extern "C" {
21  void qh_exit(int exitcode);
22 }
23 
24 #include <stdexcept>
25 #include <stdlib.h>
26 
27 /*-<a href="qh-user_r.htm#TOC"
28  >-------------------------------</a><a name="qh_exit">-</a>
29 
30  qh_exit( exitcode )
31  exit program
32 
33  notes:
34  same as exit()
35 */
36 void qh_exit(int exitcode) {
37  exitcode= exitcode;
38  throw std::runtime_error("QH10003 Qhull error. See stderr or errfile.");
39 } /* exit */
40 
41 /*-<a href="qh-user_r.htm#TOC"
42  >-------------------------------</a><a name="qh_fprintf_stderr">-</a>
43 
44  qh_fprintf_stderr( msgcode, format, list of args )
45  fprintf to stderr with msgcode (non-zero)
46 
47  notes:
48  qh_fprintf_stderr() is called when qh->ferr is not defined, usually due to an initialization error
49 
50  It is typically followed by qh_errexit().
51 
52  Redefine this function to avoid using stderr
53 
54  Use qh_fprintf [userprintf_r.c] for normal printing
55 */
56 void qh_fprintf_stderr(int msgcode, const char *fmt, ... ) {
57  va_list args;
58 
59  va_start(args, fmt);
60  if(msgcode)
61  fprintf(stderr, "QH%.4d ", msgcode);
62  vfprintf(stderr, fmt, args);
63  va_end(args);
64 } /* fprintf_stderr */
65 
66 /*-<a href="qh-user_r.htm#TOC"
67 >-------------------------------</a><a name="qh_free">-</a>
68 
69  qh_free(qhT *qh, mem )
70  free memory
71 
72  notes:
73  same as free()
74  No calls to qh_errexit()
75 */
76 void qh_free(void *mem) {
77  free(mem);
78 } /* free */
79 
80 /*-<a href="qh-user_r.htm#TOC"
81  >-------------------------------</a><a name="qh_malloc">-</a>
82 
83  qh_malloc( mem )
84  allocate memory
85 
86  notes:
87  same as malloc()
88 */
89 void *qh_malloc(size_t size) {
90  return malloc(size);
91 } /* malloc */
92 
93 
obb.fmt
fmt
Definition: obb.py:145
qh_fprintf_stderr
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
Definition: usermem_r-cpp.cpp:56
doxygen_xml_parser.args
args
Definition: doxygen_xml_parser.py:887
qh_malloc
void * qh_malloc(size_t size)
Definition: usermem_r-cpp.cpp:89
qh_free
void qh_free(void *mem)
Definition: usermem_r-cpp.cpp:76
qh_exit
void qh_exit(int exitcode)
Definition: usermem_r-cpp.cpp:36


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:59