On Mon, Jun 18, 2012 at 12:43 AM, yao liufeng <ylf...@163.com> wrote: > can someone help to clarify whether it's a > memory leak or something wrong with the code? Thanks!
Googling around, it seems like in the past year or two there's been some flareup between C99/C1X, POSIX, and glibc about interpretations of what the right/acceptable/conforming behavior of realloc(p,0) is: http://austingroupbugs.net/view.php?id=400 http://sourceware.org/bugzilla/show_bug.cgi?id=12547 In practice, on Fedora 16 (glibc 2.14), I've observed a very small leak on code like yours (you can even leave libev out of this, it's all about alloc/dealloc cycles using only the realloc() interface), which is fixable by replacing realloc(p,0) calls with free(p). libev already works around realloc(p,0) on non-glibc targets, it may just have to not use realloc(p,0) anywhere now as the simplest solution. You can test for yourself whether that's the issue by doing something like: void* my_realloc(void* ptr, long size) { if(size) return realloc(ptr, size); free(ptr); return 0; } ev_set_allocator(my_realloc); -- Brandon _______________________________________________ libev mailing list libev@lists.schmorp.de http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev