Advertisement
Weegee

Untitled

Aug 16th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. struct event * create_event(struct eventlist * list_ev, float time, void(* func)(void *), int arg_count, ...)
  2. {
  3.     va_list ptr;
  4.     int i;
  5.     struct event_arg_list * list_eva = malloc(sizeof(struct event_arg_list));
  6.     struct event_arg_list * list_eva_next;
  7.     struct event * ev_new = malloc(sizeof(struct event));
  8.    
  9.     va_start(ptr, arg_count);
  10.     for (i = 0; i < arg_count; i++)
  11.     {
  12.         /* ??? */
  13.     }
  14.     va_end(ptr);
  15.    
  16.     ev_new->start = clock();
  17.     ev_new->time = (clock_t) time * CLOCKS_PER_SEC;
  18.     ev_new->func = func;
  19.     ev_new->arg = /* ??? */
  20.    
  21.     if (list_ev->tail != NULL)
  22.     {
  23.         list_ev->tail->next = ev_new;
  24.     }
  25.    
  26.     if (list_ev->count == 0)
  27.     {
  28.         assert(list_ev->head == NULL && list_ev->tail == NULL);
  29.         list_ev->head = ev_new;
  30.     }
  31.    
  32.     list_ev->tail = ev_new;
  33.     list_ev->count++;
  34.    
  35.     while (list_eva != NULL)
  36.     {
  37.         list_eva_next = list_eva->next;
  38.         free(list_eva);
  39.         list_eva = list_eva_next;
  40.     }
  41.    
  42.     /* Debug */
  43.     fprintf(debuglog, "create_event()\n\tCreated event %p\n", (void *) ev_new);
  44.     fflush(debuglog);
  45.    
  46.     return ev_new;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement