--- libev/ev.c 2008/05/05 20:47:33 1.231 +++ libev/ev.c 2008/05/06 15:29:58 1.232 @@ -522,6 +522,8 @@ /*****************************************************************************/ +#define MALLOC_ROUND 4096 // prefer to allocate in chunks of this size, must be 2**n and >> 4 longs + int inline_size array_nextsize (int elem, int cur, int cnt) { @@ -531,11 +533,11 @@ ncur <<= 1; while (cnt > ncur); - /* if size > 4096, round to 4096 - 4 * longs to accomodate malloc overhead */ - if (elem * ncur > 4096) + /* if size is large, round to MALLOC_ROUND - 4 * longs to accomodate malloc overhead */ + if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) { ncur *= elem; - ncur = (ncur + elem + 4095 + sizeof (void *) * 4) & ~4095; + ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); ncur = ncur - sizeof (void *) * 4; ncur /= elem; } @@ -914,7 +916,7 @@ #if EV_USE_EVENTFD if (evfd >= 0) { - uint64_t counter = 1; + uint64_t counter; read (evfd, &counter, sizeof (uint64_t)); } else