wrote:
>>What about:
>>
>>if ((bucket != NULL) && (*bucket != NULL)) /**bucket instead of
>>bucket* ?*/
> And also:
>
> event **bucket = getbucket(key);
>
> depending what getbucket() returns, it seems redundant to check the
> value of bucket so many times. Either getbucket() returns something,
> or then it doesn't. No need to check if ((bucket != NULL) && (bucket* !
> = NULL))
>
> Actually when I think about it, what do you think you would find in
> *bucket?
If bucket is not NULL, then the key was a valid key for
a time tick currently indexed in the table and bucket
is the address of an event pointer somewhere in the array.
The pointer that bucket /points/ to, on the other hand,
should point at an event scheduled to happen in that time
tick (with a 'next' field for more events in the same
bucket). I get the pointer's address in bucket rather
than its value, because I will need to change its value
when "popping" an event out of the time-tick bucket.
The if statement above should translate as "if the bucket
exists and is nonempty then..." Because if bucket is NULL
then the list doesn't exist, and if the pointer bucket points
at is NULL then the list exists (ie, the time tick is in
the current range covered by the table) but no events are
scheduled in it.
Anyway, you have to check if bucket is NULL first. If it
is, you really don't want to check the value of *bucket.
Bear