Line data Source code
1 : /*<html><pre> -<a href="qh-user_r.htm" 2 : >-------------------------------</a><a name="TOP">-</a> 3 : 4 : usermem_r.c 5 : user redefinable functions -- qh_exit, qh_free, and qh_malloc 6 : 7 : See README.txt. 8 : 9 : If you redefine one of these functions you must redefine all of them. 10 : If you recompile and load this file, then usermem.o will not be loaded 11 : from qhull.a or qhull.lib 12 : 13 : See libqhull_r.h for data structures, macros, and user-callable functions. 14 : See user_r.c for qhull-related, redefinable functions 15 : see user_r.h for user-definable constants 16 : See userprintf_r.c for qh_fprintf and userprintf_rbox_r.c for qh_fprintf_rbox 17 : 18 : Please report any errors that you fix to qhull@qhull.org 19 : */ 20 : 21 : #include "libqhull_r.h" 22 : 23 : #include <stdarg.h> 24 : #include <stdlib.h> 25 : 26 : /*-<a href="qh-user_r.htm#TOC" 27 : >-------------------------------</a><a name="qh_exit">-</a> 28 : 29 : qh_exit( exitcode ) 30 : exit program 31 : the exitcode must be 255 or less. Zero indicates success. 32 : Note: Exit status ('$?') in bash reports 256 as 0 33 : 34 : notes: 35 : qh_exit() is called when qh_errexit() and longjmp() are not available. 36 : 37 : This is the only use of exit() in Qhull 38 : To replace qh_exit with 'throw', see libqhullcpp/usermem_r-cpp.cpp 39 : */ 40 0 : void qh_exit(int exitcode) { 41 0 : exit(exitcode); 42 : } /* exit */ 43 : 44 : /*-<a href="qh-user_r.htm#TOC" 45 : >-------------------------------</a><a name="qh_fprintf_stderr">-</a> 46 : 47 : qh_fprintf_stderr( msgcode, format, list of args ) 48 : fprintf to stderr with msgcode (non-zero) 49 : 50 : notes: 51 : qh_fprintf_stderr() is called when qh.ferr is not defined, usually due to an initialization error 52 : if msgcode is a MSG_ERROR (6000), caller should set qh.last_errcode (like qh_fprintf) or variable 'last_errcode' 53 : 54 : It is typically followed by qh_errexit(). 55 : 56 : Redefine this function to avoid using stderr 57 : 58 : Use qh_fprintf [userprintf_r.c] for normal printing 59 : */ 60 0 : void qh_fprintf_stderr(int msgcode, const char *fmt, ... ) { 61 : va_list args; 62 : 63 0 : va_start(args, fmt); 64 0 : if(msgcode) 65 0 : fprintf(stderr, "QH%.4d ", msgcode); 66 0 : vfprintf(stderr, fmt, args); 67 0 : va_end(args); 68 0 : } /* fprintf_stderr */ 69 : 70 : /*-<a href="qh-user_r.htm#TOC" 71 : >-------------------------------</a><a name="qh_free">-</a> 72 : 73 : qh_free(qh, mem ) 74 : free memory 75 : 76 : notes: 77 : same as free() 78 : No calls to qh_errexit() 79 : */ 80 40838 : void qh_free(void *mem) { 81 40838 : free(mem); 82 40838 : } /* free */ 83 : 84 : /*-<a href="qh-user_r.htm#TOC" 85 : >-------------------------------</a><a name="qh_malloc">-</a> 86 : 87 : qh_malloc( mem ) 88 : allocate memory 89 : 90 : notes: 91 : same as malloc() 92 : */ 93 40830 : void *qh_malloc(size_t size) { 94 40830 : return malloc(size); 95 : } /* malloc */ 96 : 97 :