Could anyone help me? Any help be much appreciated.
Thanks,Jie
 

     On Thursday, May 7, 2015 12:45 AM, Jie Liu <[email protected]> wrote:
   

 When I'm reading the code of libev, I find this definition of "array_needsize":
#define array_needsize(type,base,cur,cnt,init)            \
  if (expect_false ((cnt) > (cur)))                \
    {                                \
      int ecb_unused ocur_ = (cur);                    \
      (base) = (type *)array_realloc                \
         (sizeof (type), (base), &(cur), (cnt));        \
      init ((base) + (ocur_), (cur) - ocur_);            \
    }
According to the comments, memories are allocated in chunks of "MALLOC_ROUND". 
It is possible that the size needed is larger than "MALLOC_ROUND". In this 
case, the "array_needsize" may not allocate enough memories because it is using 
"if" instead of "while". I though there would be a "while" loop but I didn't 
find it. The library is proved by many projects, so I must miss something here. 
Could anyone point out how it works?
Thanks,Jie



  
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to