alloc.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <refentry id="refalloc">
  2. <refmeta>
  3. <refentrytitle>ne_malloc</refentrytitle>
  4. <manvolnum>3</manvolnum>
  5. </refmeta>
  6. <refnamediv>
  7. <refname id="ne_malloc">ne_malloc</refname>
  8. <refname id="ne_calloc">ne_calloc</refname>
  9. <refname id="ne_realloc">ne_realloc</refname>
  10. <refname id="ne_strdup">ne_strdup</refname>
  11. <refname id="ne_strndup">ne_strndup</refname>
  12. <refname id="ne_oom_callback">ne_oom_callback</refname>
  13. <refpurpose>memory allocation wrappers</refpurpose>
  14. </refnamediv>
  15. <refsynopsisdiv>
  16. <funcsynopsis>
  17. <funcsynopsisinfo>#include &lt;ne_alloc.h&gt;</funcsynopsisinfo>
  18. <funcprototype>
  19. <funcdef>void *<function>ne_malloc</function></funcdef>
  20. <paramdef>size_t <parameter>size</parameter></paramdef>
  21. </funcprototype>
  22. <funcprototype>
  23. <funcdef>void *<function>ne_calloc</function></funcdef>
  24. <paramdef>size_t <parameter>size</parameter></paramdef>
  25. </funcprototype>
  26. <funcprototype>
  27. <funcdef>void *<function>ne_realloc</function></funcdef>
  28. <paramdef>void *<parameter>size</parameter></paramdef>
  29. <paramdef>size_t <parameter>len</parameter></paramdef>
  30. </funcprototype>
  31. <funcprototype>
  32. <funcdef>char *<function>ne_strdup</function></funcdef>
  33. <paramdef>const char *<parameter>s</parameter></paramdef>
  34. </funcprototype>
  35. <funcprototype>
  36. <funcdef>char *<function>ne_strndup</function></funcdef>
  37. <paramdef>const char *<parameter>s</parameter></paramdef>
  38. <paramdef>size_t <parameter>size</parameter></paramdef>
  39. </funcprototype>
  40. <funcprototype>
  41. <funcdef>void <function>ne_oom_callback</function></funcdef>
  42. <paramdef>void (*<parameter>callback</parameter>)(void)</paramdef>
  43. </funcprototype>
  44. </funcsynopsis>
  45. </refsynopsisdiv>
  46. <refsect1>
  47. <title>Description</title>
  48. <para>The functions <function>ne_malloc</function>,
  49. <function>ne_calloc</function>, <function>ne_realloc</function>,
  50. <function>ne_strdup</function> and <function>ne_strdnup</function>
  51. provide wrappers for the equivalent functions in the standard C
  52. library. The wrappers provide the extra guarantee that if the C
  53. library equivalent returns &null; when no memory is available, an
  54. optional callback will be called, and the library will then call
  55. <function>abort</function>().</para>
  56. <para><function>ne_oom_callback</function> registers a callback
  57. which will be invoked if an out of memory error is detected.</para>
  58. </refsect1>
  59. <refsect1>
  60. <title>Notes</title>
  61. <para>If the operating system uses optimistic memory
  62. allocation, the C library memory allocation routines will not return
  63. &null;, so it is not possible to gracefully handle memory allocation
  64. failures.</para>
  65. </refsect1>
  66. </refentry>