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.

97 lines
3.0 KiB

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