1 /* xlp_timeout.c - data structures for registering callbacks for timeouts
2
3 Copyright 2001 Carl Worth
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <sys/time.h>
19
20 #include "xlp_timeout.h"
21
22 #ifdef DMALLOC
23 #include "dmalloc.h"
24 #endif
25
xlp_timeout_init(xlp_timeout_t * to,long delay_ms,pthread_mutex_t * mutex,xlp_to_fun_t to_fun,void * data)26 int xlp_timeout_init(xlp_timeout_t *to, long delay_ms,
27 pthread_mutex_t *mutex, xlp_to_fun_t to_fun, void *data)
28 {
29 gettimeofday(&to->start_tv, NULL);
30 to->delay_ms = delay_ms;
31 to->mutex = mutex;
32 to->to_fun = to_fun;
33 to->data = data;
34 to->next = NULL;
35
36 return 0;
37 }
38
xlp_timeout_deinit(xlp_timeout_t * to)39 void xlp_timeout_deinit(xlp_timeout_t *to)
40 {
41 to->delay_ms = 0;
42 to->mutex = NULL;
43 to->to_fun = NULL;
44 to->data = NULL;
45 to->next = NULL;
46 }
47