int fdevent_register(fdevents *ev,int fd,fdevent_handler handler,void *ctx){ fdnode *fdn; fdn=fdnode_init(); fdn->handler=handler; fdn->fd=fd; fdn->ctx=ctx; ev->fdarray[fd]=fdn; return 0; }
// //注册文件描述符fd和处理函数handler。 //及ctx int fdevent_register(fdevents * ev, int fd, fdevent_handler handler, void *ctx) { fdnode *fdn; fdn = fdnode_init(); fdn->handler = handler; fdn->fd = fd; fdn->ctx = ctx; ev->fdarray[fd] = fdn; //使用文件描述符作为数组的下标。可以将查询的时间变为O(1) return 0; }