--- libev/ev.c 2008/04/06 14:34:50 1.223 +++ libev/ev.c 2008/04/09 22:07:50 1.224 @@ -362,7 +362,22 @@ } } -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 @@ inline_speed void * ev_realloc (void *ptr, long size) { - ptr = alloc ? alloc (ptr, size) : realloc (ptr, size); + ptr = alloc (ptr, size); if (!ptr && size) {