fs/epoll: Double array size when it is full

correct the sequnce of array size from:
size, size, 2*size, 4*size, 8*size...
to:
size, 2*size, 4*size, 8*size, 16*size...

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-07-28 20:27:28 +08:00 committed by Petro Karashchenko
parent 56b2e7254a
commit 7c1768c167
1 changed files with 2 additions and 3 deletions

View File

@ -535,21 +535,20 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
*/
extend = kmm_zalloc(sizeof(*extend) +
sizeof(epoll_node_t) * eph->size);
2 * sizeof(epoll_node_t) * eph->size);
if (extend == NULL)
{
ret = -ENOMEM;
goto err;
}
eph->size *= 2;
list_add_tail(&eph->extend, extend);
epn = (FAR epoll_node_t *)(extend + 1);
for (i = 0; i < eph->size; i++)
{
list_add_tail(&eph->free, &epn[i].node);
}
eph->size += eph->size;
}
epn = container_of(list_remove_head(&eph->free), epoll_node_t, node);