Less ridiculous time calculation

svn path=/trunk/netsurf/; revision=11826
This commit is contained in:
Chris Young 2011-02-26 12:54:56 +00:00
parent 8b1a36e2db
commit 6eb8783632
1 changed files with 4 additions and 7 deletions

View File

@ -51,18 +51,15 @@ void schedule(int t, void (*callback)(void *p), void *p)
{
struct nscallback *nscb;
struct timeval tv;
ULONG time_us = 0;
nscb = AllocVec(sizeof(struct nscallback), MEMF_PRIVATE | MEMF_CLEAR);
if(!nscb) return;
nscb->tv.Seconds = 0;
nscb->tv.Microseconds = t*10000;
time_us = t*10000; /* t converted to µs */
while(nscb->tv.Microseconds >= 1000000)
{
nscb->tv.Seconds++;
nscb->tv.Microseconds -= 1000000;
}
nscb->tv.Seconds = time_us / 1000000;
nscb->tv.Microseconds = time_us % 1000000;
GetSysTime(&tv);
AddTime(&nscb->tv,&tv); // now contains time when event occurs