From 0ce28cbfed5d711405dbfd85f7321b824842e47a Mon Sep 17 00:00:00 2001 From: Stef Date: Sat, 27 Nov 2010 15:50:58 +0000 Subject: Redo raw scrounge so that it's faster. --- src/misc.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/misc.c') diff --git a/src/misc.c b/src/misc.c index 255533f..4163348 100644 --- a/src/misc.c +++ b/src/misc.c @@ -60,25 +60,27 @@ void addLocationLock(drivelocks* locks, uint64 beg, uint64 end) } } -bool checkLocationLock(drivelocks* locks, uint64 sec) +uint64 checkLocationLock(drivelocks* locks, uint64 sec) { - uint32 i; + uint64 locked; + uint32 i; - if(locks->_locks) - { - /* Go through and check for a lock */ - for(i = 0; i < locks->_current; i++) - { - if(sec >= locks->_locks[i].beg && - sec < locks->_locks[i].end) - { - sec = locks->_locks[i].end; - return true; - } - } + if(locks->_locks) + { + /* Go through and check for a lock */ + for(i = 0; i < locks->_current; i++) + { + if(sec >= locks->_locks[i].beg && + sec < locks->_locks[i].end) + { + locked = locks->_locks[i].end - sec; + assert(locked != 0); + return locked; + } + } } - return false; + return 0; } #ifdef _DEBUG -- cgit v1.2.3