3 <!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
5 <TITLE>CLN, a Class Library for Numbers - 12. Customizing</TITLE>
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>.
12 <H1><A NAME="SEC70" HREF="cln_toc.html#TOC70">12. Customizing</A></H1>
19 <H2><A NAME="SEC71" HREF="cln_toc.html#TOC71">12.1 Error handling</A></H2>
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
29 #include <cln/abort.h>
35 This function must not return control to its caller.
40 <H2><A NAME="SEC72" HREF="cln_toc.html#TOC72">12.2 Floating-point underflow</A></H2>
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
52 cl_boolean cl_inhibit_floating_point_underflow
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>.
63 <H2><A NAME="SEC73" HREF="cln_toc.html#TOC73">12.3 Customizing I/O</A></H2>
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>.
73 <H2><A NAME="SEC74" HREF="cln_toc.html#TOC74">12.4 Customizing the memory allocator</A></H2>
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,
86 #include <cln/malloc.h>
88 void* (*malloc_hook) (size_t size) = ...;
89 void (*free_hook) (void* ptr) = ...;
96 The <CODE>cl_malloc_hook</CODE> function must not return a <CODE>NULL</CODE> pointer.
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
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>.