; rdi - fd pollfds__remove: mov rax, [pollfds_len] mov rsi, 0 call pollfds__remove__loop mov [pollfds_len], rax ret ; Variables: ; rax - array length ; rdi - fd ; rsi - array index ; r11d - pollfds[rdi].fd pollfds__remove__loop: cmp rsi, rax jge return ; fd was not found mov r11d, [pollfds + rsi * pollfd_size] add rsi, 1 cmp r11d, edi jne pollfds__remove__loop sub rsi, 1 ; rax - array length ; rsi - array index to remove pollfds__remove_index: cmp rax, 1 jle pollfds__clear mov r10d, [pollfds + (rax - 1) * pollfd_size] mov [pollfds + rsi * pollfd_size], r10d sub rax, 1 ret ; Returns new array length in rax pollfds__clear: mov rax, 0 ret