You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.2 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. <HTML>
  2. <HEAD>
  3. <!-- Created by texi2html 1.56k from cln.texi on 4 May 2000 -->
  4. <TITLE>CLN, a Class Library for Numbers - 12. Customizing</TITLE>
  5. </HEAD>
  6. <BODY>
  7. 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>.
  8. <P><HR><P>
  9. <H1><A NAME="SEC68" HREF="cln_toc.html#TOC68">12. Customizing</A></H1>
  10. <P>
  11. <A NAME="IDX316"></A>
  12. <H2><A NAME="SEC69" HREF="cln_toc.html#TOC69">12.1 Error handling</A></H2>
  13. <P>
  14. When a fatal error occurs, an error message is output to the standard error
  15. output stream, and the function <CODE>cl_abort</CODE> is called. The default
  16. version of this function (provided in the library) terminates the application.
  17. To catch such a fatal error, you need to define the function <CODE>cl_abort</CODE>
  18. yourself, with the prototype
  19. <PRE>
  20. #include &#60;cl_abort.h&#62;
  21. void cl_abort (void);
  22. </PRE>
  23. <P>
  24. <A NAME="IDX317"></A>
  25. This function must not return control to its caller.
  26. <H2><A NAME="SEC70" HREF="cln_toc.html#TOC70">12.2 Floating-point underflow</A></H2>
  27. <P>
  28. <A NAME="IDX318"></A>
  29. <P>
  30. Floating point underflow denotes the situation when a floating-point number
  31. is to be created which is so close to <CODE>0</CODE> that its exponent is too
  32. low to be represented internally. By default, this causes a fatal error.
  33. If you set the global variable
  34. <PRE>
  35. cl_boolean cl_inhibit_floating_point_underflow
  36. </PRE>
  37. <P>
  38. to <CODE>cl_true</CODE>, the error will be inhibited, and a floating-point zero
  39. will be generated instead. The default value of
  40. <CODE>cl_inhibit_floating_point_underflow</CODE> is <CODE>cl_false</CODE>.
  41. <H2><A NAME="SEC71" HREF="cln_toc.html#TOC71">12.3 Customizing I/O</A></H2>
  42. <P>
  43. The output of the function <CODE>fprint</CODE> may be customized by changing the
  44. value of the global variable <CODE>cl_default_print_flags</CODE>.
  45. <A NAME="IDX319"></A>
  46. <H2><A NAME="SEC72" HREF="cln_toc.html#TOC72">12.4 Customizing the memory allocator</A></H2>
  47. <P>
  48. Every memory allocation of CLN is done through the function pointer
  49. <CODE>cl_malloc_hook</CODE>. Freeing of this memory is done through the function
  50. pointer <CODE>cl_free_hook</CODE>. The default versions of these functions,
  51. provided in the library, call <CODE>malloc</CODE> and <CODE>free</CODE> and check
  52. the <CODE>malloc</CODE> result against <CODE>NULL</CODE>.
  53. If you want to provide another memory allocator, you need to define
  54. the variables <CODE>cl_malloc_hook</CODE> and <CODE>cl_free_hook</CODE> yourself,
  55. like this:
  56. <PRE>
  57. #include &#60;cl_malloc.h&#62;
  58. void* (*cl_malloc_hook) (size_t size) = ...;
  59. void (*cl_free_hook) (void* ptr) = ...;
  60. </PRE>
  61. <P>
  62. <A NAME="IDX320"></A>
  63. <A NAME="IDX321"></A>
  64. The <CODE>cl_malloc_hook</CODE> function must not return a <CODE>NULL</CODE> pointer.
  65. <P>
  66. It is not possible to change the memory allocator at runtime, because
  67. it is already called at program startup by the constructors of some
  68. global variables.
  69. <P><HR><P>
  70. 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>.
  71. </BODY>
  72. </HTML>