| 1 |
'\" t |
| 2 |
.\" Title: ne_malloc |
| 3 |
.\" Author: |
| 4 |
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/> |
| 5 |
.\" Date: 3 May 2011 |
| 6 |
.\" Manual: neon API reference |
| 7 |
.\" Source: neon 0.29.6 |
| 8 |
.\" Language: English |
| 9 |
.\" |
| 10 |
.TH "NE_MALLOC" "3" "3 May 2011" "neon 0.29.6" "neon API reference" |
| 11 |
.\" ----------------------------------------------------------------- |
| 12 |
.\" * Define some portability stuff |
| 13 |
.\" ----------------------------------------------------------------- |
| 14 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 15 |
.\" http://bugs.debian.org/507673 |
| 16 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 17 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 18 |
.ie \n(.g .ds Aq \(aq |
| 19 |
.el .ds Aq ' |
| 20 |
.\" ----------------------------------------------------------------- |
| 21 |
.\" * set default formatting |
| 22 |
.\" ----------------------------------------------------------------- |
| 23 |
.\" disable hyphenation |
| 24 |
.nh |
| 25 |
.\" disable justification (adjust text to left margin only) |
| 26 |
.ad l |
| 27 |
.\" ----------------------------------------------------------------- |
| 28 |
.\" * MAIN CONTENT STARTS HERE * |
| 29 |
.\" ----------------------------------------------------------------- |
| 30 |
.SH "NAME" |
| 31 |
ne_malloc, ne_calloc, ne_realloc, ne_strdup, ne_strndup, ne_oom_callback \- memory allocation wrappers |
| 32 |
.SH "SYNOPSIS" |
| 33 |
.sp |
| 34 |
.ft B |
| 35 |
.nf |
| 36 |
#include <ne_alloc\&.h> |
| 37 |
.fi |
| 38 |
.ft |
| 39 |
.HP \w'void\ *ne_malloc('u |
| 40 |
.BI "void *ne_malloc(size_t\ " "size" ");" |
| 41 |
.HP \w'void\ *ne_calloc('u |
| 42 |
.BI "void *ne_calloc(size_t\ " "size" ");" |
| 43 |
.HP \w'void\ *ne_realloc('u |
| 44 |
.BI "void *ne_realloc(void\ *" "size" ", size_t\ " "len" ");" |
| 45 |
.HP \w'char\ *ne_strdup('u |
| 46 |
.BI "char *ne_strdup(const\ char\ *" "s" ");" |
| 47 |
.HP \w'char\ *ne_strndup('u |
| 48 |
.BI "char *ne_strndup(const\ char\ *" "s" ", size_t\ " "size" ");" |
| 49 |
.HP \w'void\ ne_oom_callback('u |
| 50 |
.BI "void ne_oom_callback(void\ (*" "callback" ")(void));" |
| 51 |
.SH "DESCRIPTION" |
| 52 |
.PP |
| 53 |
The functions |
| 54 |
\fBne_malloc\fR, |
| 55 |
\fBne_calloc\fR, |
| 56 |
\fBne_realloc\fR, |
| 57 |
\fBne_strdup\fR |
| 58 |
and |
| 59 |
\fBne_strdnup\fR |
| 60 |
provide wrappers for the equivalent functions in the standard C library\&. The wrappers provide the extra guarantee that if the C library equivalent returns |
| 61 |
NULL |
| 62 |
when no memory is available, an optional callback will be called, and the library will then call |
| 63 |
\fBabort\fR()\&. |
| 64 |
.PP |
| 65 |
\fBne_oom_callback\fR |
| 66 |
registers a callback which will be invoked if an out of memory error is detected\&. |
| 67 |
.SH "NOTES" |
| 68 |
.PP |
| 69 |
If the operating system uses optimistic memory allocation, the C library memory allocation routines will not return |
| 70 |
NULL, so it is not possible to gracefully handle memory allocation failures\&. |
| 71 |
.SH "AUTHOR" |
| 72 |
.PP |
| 73 |
\fBJoe Orton\fR <\&[email protected]\&> |
| 74 |
.RS 4 |
| 75 |
Author. |
| 76 |
.RE |
| 77 |
.SH "COPYRIGHT" |
| 78 |
.br |