* Remove the timer from the current list and free it up. Return the time * remaining until it would have gone off, 0 if not found. */
| 2296 | * remaining until it would have gone off, 0 if not found. |
| 2297 | */ |
| 2298 | long |
| 2299 | stop_timer(short func_index, anything *arg) |
| 2300 | { |
| 2301 | timeout_proc cleanup_func; |
| 2302 | timer_element *doomed; |
| 2303 | long timeout; |
| 2304 | |
| 2305 | doomed = remove_timer(>.timer_base, func_index, arg); |
| 2306 | |
| 2307 | if (doomed) { |
| 2308 | timeout = doomed->timeout; |
| 2309 | if (doomed->kind == TIMER_OBJECT) |
| 2310 | (arg->a_obj)->timed--; |
| 2311 | if ((cleanup_func = timeout_funcs[doomed->func_index].cleanup) != 0) |
| 2312 | (*cleanup_func)(arg, timeout); |
| 2313 | (void) memset((genericptr_t) doomed, 0, sizeof(timer_element)); |
| 2314 | free((genericptr_t) doomed); |
| 2315 | return (timeout - svm.moves); |
| 2316 | } |
| 2317 | return 0L; |
| 2318 | } |
| 2319 | |
| 2320 | /* |
| 2321 | * Find the timeout of specified timer; return 0 if none. |
no test coverage detected