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

Comparing libev/ev.pod (file contents):
Revision 1.51 by root, Tue Nov 27 19:23:31 2007 UTC vs.
Revision 1.52 by root, Tue Nov 27 19:41:52 2007 UTC

115C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for 115C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for
116recommended ones. 116recommended ones.
117 117
118See the description of C<ev_embed> watchers for more info. 118See the description of C<ev_embed> watchers for more info.
119 119
120=item ev_set_allocator (void *(*cb)(void *ptr, long size)) 120=item ev_set_allocator (void *(*cb)(void *ptr, size_t size))
121 121
122Sets the allocation function to use (the prototype is similar to the 122Sets the allocation function to use (the prototype and semantics are
123realloc C function, the semantics are identical). It is used to allocate 123identical to the realloc C function). It is used to allocate and free
124and free memory (no surprises here). If it returns zero when memory 124memory (no surprises here). If it returns zero when memory needs to be
125needs to be allocated, the library might abort or take some potentially 125allocated, the library might abort or take some potentially destructive
126destructive action. The default is your system realloc function. 126action. The default is your system realloc function.
127 127
128You could override this function in high-availability programs to, say, 128You could override this function in high-availability programs to, say,
129free some memory if it cannot allocate memory, to use a special allocator, 129free some memory if it cannot allocate memory, to use a special allocator,
130or even to sleep a while and retry until some memory is available. 130or even to sleep a while and retry until some memory is available.
131 131
132Example: replace the libev allocator with one that waits a bit and then 132Example: replace the libev allocator with one that waits a bit and then
133retries: better than mine). 133retries: better than mine).
134 134
135 static void * 135 static void *
136 persistent_realloc (void *ptr, long size) 136 persistent_realloc (void *ptr, size_t size)
137 { 137 {
138 for (;;) 138 for (;;)
139 { 139 {
140 void *newptr = realloc (ptr, size); 140 void *newptr = realloc (ptr, size);
141 141

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines