]> www.ginac.de Git - cln.git/blob - doc/cln_12.html
* All Files have been modified for inclusion of namespace cln;
[cln.git] / doc / cln_12.html
1 <HTML>
2 <HEAD>
3 <!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
4
5 <TITLE>CLN, a Class Library for Numbers - 12. Customizing</TITLE>
6 </HEAD>
7 <BODY>
8 Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_11.html">previous</A>, <A HREF="cln_13.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
9 <P><HR><P>
10
11
12 <H1><A NAME="SEC70" HREF="cln_toc.html#TOC70">12. Customizing</A></H1>
13 <P>
14 <A NAME="IDX342"></A>
15
16
17
18
19 <H2><A NAME="SEC71" HREF="cln_toc.html#TOC71">12.1 Error handling</A></H2>
20
21 <P>
22 When a fatal error occurs, an error message is output to the standard error
23 output stream, and the function <CODE>cl_abort</CODE> is called. The default
24 version of this function (provided in the library) terminates the application.
25 To catch such a fatal error, you need to define the function <CODE>cl_abort</CODE>
26 yourself, with the prototype
27
28 <PRE>
29 #include &#60;cln/abort.h&#62;
30 void cl_abort (void);
31 </PRE>
32
33 <P>
34 <A NAME="IDX343"></A>
35 This function must not return control to its caller.
36
37
38
39
40 <H2><A NAME="SEC72" HREF="cln_toc.html#TOC72">12.2 Floating-point underflow</A></H2>
41 <P>
42 <A NAME="IDX344"></A>
43
44
45 <P>
46 Floating point underflow denotes the situation when a floating-point number
47 is to be created which is so close to <CODE>0</CODE> that its exponent is too
48 low to be represented internally. By default, this causes a fatal error.
49 If you set the global variable
50
51 <PRE>
52 cl_boolean cl_inhibit_floating_point_underflow
53 </PRE>
54
55 <P>
56 to <CODE>cl_true</CODE>, the error will be inhibited, and a floating-point zero
57 will be generated instead.  The default value of 
58 <CODE>cl_inhibit_floating_point_underflow</CODE> is <CODE>cl_false</CODE>.
59
60
61
62
63 <H2><A NAME="SEC73" HREF="cln_toc.html#TOC73">12.3 Customizing I/O</A></H2>
64
65 <P>
66 The output of the function <CODE>fprint</CODE> may be customized by changing the
67 value of the global variable <CODE>default_print_flags</CODE>.
68 <A NAME="IDX345"></A>
69
70
71
72
73 <H2><A NAME="SEC74" HREF="cln_toc.html#TOC74">12.4 Customizing the memory allocator</A></H2>
74
75 <P>
76 Every memory allocation of CLN is done through the function pointer
77 <CODE>malloc_hook</CODE>. Freeing of this memory is done through the function
78 pointer <CODE>free_hook</CODE>. The default versions of these functions,
79 provided in the library, call <CODE>malloc</CODE> and <CODE>free</CODE> and check
80 the <CODE>malloc</CODE> result against <CODE>NULL</CODE>.
81 If you want to provide another memory allocator, you need to define
82 the variables <CODE>malloc_hook</CODE> and <CODE>free_hook</CODE> yourself,
83 like this:
84
85 <PRE>
86 #include &#60;cln/malloc.h&#62;
87 namespace cln {
88         void* (*malloc_hook) (size_t size) = ...;
89         void (*free_hook) (void* ptr)      = ...;
90 }
91 </PRE>
92
93 <P>
94 <A NAME="IDX346"></A>
95 <A NAME="IDX347"></A>
96 The <CODE>cl_malloc_hook</CODE> function must not return a <CODE>NULL</CODE> pointer.
97
98
99 <P>
100 It is not possible to change the memory allocator at runtime, because
101 it is already called at program startup by the constructors of some
102 global variables.
103
104
105 <P><HR><P>
106 Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_11.html">previous</A>, <A HREF="cln_13.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
107 </BODY>
108 </HTML>