mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
smbd: Factor out brl_delete_lock_struct
memmove calculations are never nice, and this is going to be used in validate_lock_entries soon :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
3c2f4e328b
commit
2282128ed0
@ -999,6 +999,17 @@ NTSTATUS brl_lock(struct messaging_context *msg_ctx,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void brl_delete_lock_struct(struct lock_struct *locks,
|
||||||
|
unsigned num_locks,
|
||||||
|
unsigned del_idx)
|
||||||
|
{
|
||||||
|
if (del_idx >= num_locks) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memmove(&locks[del_idx], &locks[del_idx+1],
|
||||||
|
sizeof(*locks) * (num_locks - del_idx - 1));
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Unlock a range of bytes - Windows semantics.
|
Unlock a range of bytes - Windows semantics.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -1066,12 +1077,7 @@ bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
|
|||||||
unlock_continue:
|
unlock_continue:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Actually delete the lock. */
|
brl_delete_lock_struct(locks, br_lck->num_locks, i);
|
||||||
if (i < br_lck->num_locks - 1) {
|
|
||||||
memmove(&locks[i], &locks[i+1],
|
|
||||||
sizeof(*locks)*((br_lck->num_locks-1) - i));
|
|
||||||
}
|
|
||||||
|
|
||||||
br_lck->num_locks -= 1;
|
br_lck->num_locks -= 1;
|
||||||
br_lck->modified = True;
|
br_lck->modified = True;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user