/* * Cancel the timer that was set for time <t> with callback <cb>. */ void disDropTime(Dispatcher *dis, double t, void (*cb)(Dispatcher *dis, double t, void *udata)) { DIS_Timer *timer; for (timer = listHead(&dis->timers); timer; timer = listNext(timer)) { if (timer->t == t && timer->cb == cb) { listRemove(&dis->timers, timer); free(timer); return; } } dbgAbort(stderr, "no such timer\n"); }
/* * Set the entry at <index> of pointer array <pa> to <ptr>. */ void paSet(PointerArray *pa, int index, void *ptr) { if (ptr == NULL) { paDrop(pa, index); } else if (index < 0) { dbgAbort(stderr, "index must be >= 0, got %d\n", index); } else if (index >= pa->num_ptrs) { int new_num_ptrs = index + 1; pa->ptr = realloc(pa->ptr, sizeof(void *) * new_num_ptrs); memset(pa->ptr + pa->num_ptrs, 0, sizeof(void *) * (new_num_ptrs - pa->num_ptrs)); pa->num_ptrs = new_num_ptrs; } pa->ptr[index] = ptr; }