ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.144 by root, Mon Apr 7 12:33:29 2008 UTC vs.
Revision 1.145 by root, Wed Apr 9 22:07:50 2008 UTC

196See the description of C<ev_embed> watchers for more info. 196See the description of C<ev_embed> watchers for more info.
197 197
198=item ev_set_allocator (void *(*cb)(void *ptr, long size)) 198=item ev_set_allocator (void *(*cb)(void *ptr, long size))
199 199
200Sets the allocation function to use (the prototype is similar - the 200Sets the allocation function to use (the prototype is similar - the
201semantics is identical - to the realloc C function). It is used to 201semantics are identical to the C<realloc> C89/SuS/POSIX function). It is
202allocate and free memory (no surprises here). If it returns zero when 202used to allocate and free memory (no surprises here). If it returns zero
203memory needs to be allocated, the library might abort or take some 203when memory needs to be allocated (C<size != 0>), the library might abort
204potentially destructive action. The default is your system realloc 204or take some potentially destructive action.
205function. 205
206Since some systems (at least OpenBSD and Darwin) fail to implement
207correct C<realloc> semantics, libev will use a wrapper around the system
208C<realloc> and C<free> functions by default.
206 209
207You could override this function in high-availability programs to, say, 210You could override this function in high-availability programs to, say,
208free some memory if it cannot allocate memory, to use a special allocator, 211free some memory if it cannot allocate memory, to use a special allocator,
209or even to sleep a while and retry until some memory is available. 212or even to sleep a while and retry until some memory is available.
210 213
211Example: Replace the libev allocator with one that waits a bit and then 214Example: Replace the libev allocator with one that waits a bit and then
212retries). 215retries (example requires a standards-compliant C<realloc>).
213 216
214 static void * 217 static void *
215 persistent_realloc (void *ptr, size_t size) 218 persistent_realloc (void *ptr, size_t size)
216 { 219 {
217 for (;;) 220 for (;;)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines