1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +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:
Volker Lendecke 2014-06-29 11:31:18 +02:00 committed by Jeremy Allison
parent 3c2f4e328b
commit 2282128ed0

View File

@ -999,6 +999,17 @@ NTSTATUS brl_lock(struct messaging_context *msg_ctx,
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.
****************************************************************************/
@ -1066,12 +1077,7 @@ bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
unlock_continue:
#endif
/* Actually delete the lock. */
if (i < br_lck->num_locks - 1) {
memmove(&locks[i], &locks[i+1],
sizeof(*locks)*((br_lck->num_locks-1) - i));
}
brl_delete_lock_struct(locks, br_lck->num_locks, i);
br_lck->num_locks -= 1;
br_lck->modified = True;