]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/EventCenter: replace malloc() and memset() with calloc()
authorChangcheng Liu <changcheng.liu@aliyun.com>
Wed, 31 Jul 2019 03:08:10 +0000 (11:08 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Tue, 10 Sep 2019 13:22:12 +0000 (21:22 +0800)
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/msg/async/EventEpoll.cc

index 3eb91238461a5b57c89cf14cf741d013a1151a32..000aaf4fcbcb0e3b710d3f3e99163a6aaed526cf 100644 (file)
 
 int EpollDriver::init(EventCenter *c, int nevent)
 {
-  events = (struct epoll_event*)malloc(sizeof(struct epoll_event)*nevent);
+  events = (struct epoll_event*)calloc(nevent, sizeof(struct epoll_event));
   if (!events) {
     lderr(cct) << __func__ << " unable to malloc memory. " << dendl;
     return -ENOMEM;
   }
-  memset(events, 0, sizeof(struct epoll_event)*nevent);
 
   epfd = epoll_create(1024); /* 1024 is just an hint for the kernel */
   if (epfd == -1) {