Skip to content

Commit

Permalink
worse worst case?
Browse files Browse the repository at this point in the history
  • Loading branch information
xzn committed Sep 6, 2024
1 parent 409866d commit 1ecc24c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions source/nwm_misc/ikcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ int ikcp_input(ikcpcb *kcp, char *data, int size)
IUINT16 nack_start = (val >> count_nbits) & ((1 << PID_NBITS) - 1);
IUINT16 nack_count_0 = size == 1 ? (1 << (PID_NBITS - 2)) - 1 : val & ((1 << count_nbits) - 1);

if (kcp->n_nacks >= sizeof(kcp->nacks) / sizeof(*kcp->nacks)) {
return -4;
}

kcp->nacks[kcp->n_nacks][0] = nack_start;
kcp->nacks[kcp->n_nacks][1] = nack_count_0;
++kcp->n_nacks;
Expand Down
4 changes: 2 additions & 2 deletions source/nwm_misc/ikcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ struct IKCPCB
#ifdef CHECK_PID
struct BitSet4096Mem pid_bs;
#endif
// Worst case every other packet is nack
u16 nacks[DIV_ROUND_UP(ARQ_PREFERRED_COUNT_MAX, 2)][2];
// Worst case between every other packet is nack
u16 nacks[ARQ_PREFERRED_COUNT_MAX][2];
u16 n_nacks;
};

Expand Down

0 comments on commit 1ecc24c

Please sign in to comment.