diff options
-rw-r--r-- | user_data.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/user_data.c b/user_data.c index 6b9b041..125a6b4 100644 --- a/user_data.c +++ b/user_data.c @@ -61,8 +61,10 @@ void userdata_unregister(i64 userid,int fd){ if(i==data->len){ die("userdata_unregister(%" PRIi64 ", %d) while nonexistent",userid,fd); } - memmove(data->fds+i,data->fds+i+1,data->len-i-1); - memmove(data->last_active+i,data->last_active+i+1,data->len-i-1); + if(i<data->len-1){ + data->fds[i]=data->fds[data->len-1]; + data->last_active[i]=data->last_active[data->len-1]; + } data->len--; if(data->len==0){ ht_delete(user_hash,userid); |