Пример #1
0
void lsystem_destroy (LSYSTEM * l) {
  while (!dynarr_isEmpty (l->p)) {
    production_destroy (*(PRODUCTION **)dynarr_pop (l->p));
  }
  dynarr_destroy (l->p);
  xph_free (l);
}
Пример #2
0
void production_destroy (PRODUCTION * p) {
  while (!dynarr_isEmpty (p->exp)) {
    xph_free (*(char **)dynarr_pop (p->exp));
  }
  dynarr_destroy (p->exp);
  xph_free (p);
}
Пример #3
0
void resman_stop_watch(struct resman *rman, struct resource *res)
{
    int i, sz;
    struct watch_dir *wdir;

    if(!res->watch_path) {
        return;
    }

    if(!(wdir = rb_find(rman->watchdirs, res->watch_path))) {
        return;
    }

    /* if there is no other reference to this watch dir, destroy it */
    if(--wdir->nref <= 0) {
        /* find the handle in the watch_handles array and remove it */
        sz = dynarr_size(rman->watch_handles);
        for(i=0; i<sz; i++) {
            if(rman->watch_handles[i] == wdir->handle) {
                /* swap the end for it and pop */
                rman->watch_handles[i] = rman->watch_handles[sz - 1];
                rman->watch_handles[sz - 1] = 0;
                dynarr_pop(rman->watch_handles);
                break;
            }
        }

        rb_delete(rman->wdirbyev, wdir->over.hEvent);
        rb_delete(rman->watchdirs, wdir->watch_path);

        CancelIo(wdir->handle);
        CloseHandle(wdir->handle);
        CloseHandle(wdir->over.hEvent);
        free(wdir->watch_path);
        free(wdir);

        res->watch_path = 0;
    } else {
        /* just remove this watch item */
        if(wdir->items && wdir->items->res == res) {
            struct watch_item *tmp = wdir->items;
            wdir->items = wdir->items->next;
            free(tmp);
        } else {
            struct watch_item *wprev = wdir->items;
            struct watch_item *witem = wprev->next;

            while(witem) {
                if(witem->res == res) {
                    struct watch_item *tmp = witem;
                    wprev->next = witem->next;
                    break;
                }
                witem = witem->next;
            }
        }
    }
}