mirror of /home/gitosis/repositories/libev.git
*** empty log message ***
parent
fe35feee50
commit
cf65f998c0
7
Changes
7
Changes
|
@ -1,5 +1,7 @@
|
|||
Revision history for libev, a high-performance and full-featured event loop.
|
||||
|
||||
- event_base_loopexit should return 0 on success
|
||||
(W.C.A. Wijngaards).
|
||||
- added linux eventfd support.
|
||||
- try to autodetect epoll and inotify support
|
||||
by libc header version if not using autoconf.
|
||||
|
@ -7,8 +9,9 @@ Revision history for libev, a high-performance and full-featured event loop.
|
|||
- declare functions defined in ev.h as inline if
|
||||
C99 or gcc are available.
|
||||
- enable inlining with gcc versions 2 and 3.
|
||||
- event_base_loopexit should return 0 on success
|
||||
(W.C.A. Wijngaards).
|
||||
- work around a bug in realloc on openbsd and darwin,
|
||||
also makes the errornous valgrind complaints
|
||||
go away (noted by various people).
|
||||
|
||||
3.2 Wed Apr 2 17:11:19 CEST 2008
|
||||
- fix a 64 bit overflow issue in the select backend,
|
||||
|
|
19
ev.c
19
ev.c
|
@ -362,7 +362,22 @@ syserr (const char *msg)
|
|||
}
|
||||
}
|
||||
|
||||
static void *(*alloc)(void *ptr, long size);
|
||||
static void *
|
||||
ev_realloc_emul (void *ptr, long size)
|
||||
{
|
||||
/* some systems, notably openbsd and darwin, fail to properly
|
||||
* implement realloc (x, 0) (as required by both ansi c-98 and
|
||||
* the single unix specification, so work around them here.
|
||||
*/
|
||||
|
||||
if (size)
|
||||
return realloc (ptr, size);
|
||||
|
||||
free (ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
|
||||
|
||||
void
|
||||
ev_set_allocator (void *(*cb)(void *ptr, long size))
|
||||
|
@ -373,7 +388,7 @@ ev_set_allocator (void *(*cb)(void *ptr, long size))
|
|||
inline_speed void *
|
||||
ev_realloc (void *ptr, long size)
|
||||
{
|
||||
ptr = alloc ? alloc (ptr, size) : realloc (ptr, size);
|
||||
ptr = alloc (ptr, size);
|
||||
|
||||
if (!ptr && size)
|
||||
{
|
||||
|
|
15
ev.pod
15
ev.pod
|
@ -198,18 +198,21 @@ See the description of C<ev_embed> watchers for more info.
|
|||
=item ev_set_allocator (void *(*cb)(void *ptr, long size))
|
||||
|
||||
Sets the allocation function to use (the prototype is similar - the
|
||||
semantics is identical - to the realloc C function). It is used to
|
||||
allocate and free memory (no surprises here). If it returns zero when
|
||||
memory needs to be allocated, the library might abort or take some
|
||||
potentially destructive action. The default is your system realloc
|
||||
function.
|
||||
semantics are identical to the C<realloc> C89/SuS/POSIX function). It is
|
||||
used to allocate and free memory (no surprises here). If it returns zero
|
||||
when memory needs to be allocated (C<size != 0>), the library might abort
|
||||
or take some potentially destructive action.
|
||||
|
||||
Since some systems (at least OpenBSD and Darwin) fail to implement
|
||||
correct C<realloc> semantics, libev will use a wrapper around the system
|
||||
C<realloc> and C<free> functions by default.
|
||||
|
||||
You could override this function in high-availability programs to, say,
|
||||
free some memory if it cannot allocate memory, to use a special allocator,
|
||||
or even to sleep a while and retry until some memory is available.
|
||||
|
||||
Example: Replace the libev allocator with one that waits a bit and then
|
||||
retries).
|
||||
retries (example requires a standards-compliant C<realloc>).
|
||||
|
||||
static void *
|
||||
persistent_realloc (void *ptr, size_t size)
|
||||
|
|
Loading…
Reference in New Issue