示例#1
0
void mt_event_destroy(mt_event e)
{
    for (int i = 0; i < e->signals.item_cnt; i++) {
        HANDLE ehdl = ((HANDLE*)e->signals.buffer)[i];
        if (ehdl != NULL)
            CloseHandle(ehdl);
    }
    arr_destroy(&e->signals);
    A_FREE(e->alloc, e);
}
示例#2
0
void wld_releasemgr()
{
    for (int i = 0; i < g_wld.sections.item_cnt; i++)    {
        struct wld_section* s = &((struct wld_section*)g_wld.sections.buffer)[i];
        wld_destroy_section(s);
    }

    arr_destroy(&g_wld.sections);
    hashtable_open_destroy(&g_wld.stable);
    wld_zero();
}
示例#3
0
void prf_releasemgr()
{
    MT_ATOMIC_SET(g_prf.init, FALSE);
    mt_mutex_release(&g_prf.samples_mtx);
	webserver_release();
	arr_destroy(&g_prf.cmds);
    if (g_prf.samples_front != NULL)
        prf_destroy_samples((struct prf_samples*)g_prf.samples_front);
    if (g_prf.samples_back != NULL)
        prf_destroy_samples((struct prf_samples*)g_prf.samples_back);
	prf_zero();
}
示例#4
0
文件: avl.c 项目: wkennington/adt
static void
avl_clear_intern (avl_t avl, int free_data)
{
  arr_t arr;
  avl_entry_t curr;
  size_t size;

  /* Create a new array to be used as a stack */
  arr = arr_init ();

  /* Iterate over every node */
  arr_insert_back (arr, avl->root);
  while ((size = arr_size (arr)) > 0)
    {
      /* Get the current element from the stack */
      curr = (avl_entry_t) arr_get (arr, size-1);
      arr_remove (arr, size-1);

      /* Check for invalid nodes */
      if (curr == NULL)
	continue;

      /* Push children onto the stack */
      arr_insert_back (arr, curr->left);
      arr_insert_back (arr, curr->right);

      /* Free parent */
      if (free_data && curr->data != NULL)
	free (curr->data);
      avl->free (curr->key);
      free (curr);
    }

  /* Cleanup the array */
  arr_destroy (arr);

  /* Update AVL Struct */
  avl->size = 0;
  avl->root = NULL;

  return;
}
示例#5
0
void rs_releasemgr()
{
    struct linked_list* unload_item = g_rs.unload_items;
    while (unload_item != NULL) {
        struct linked_list* nitem = unload_item->next;
        FREE(unload_item->data);
        unload_item = nitem;
    }

    hashtable_chained_destroy(&g_rs.dict);
    mem_pool_destroy(&g_rs.dict_itempool);
    mem_pool_destroy(&g_rs.freeslot_pool);
    arr_destroy(&g_rs.ress);
    mem_pool_destroy(&g_rs.load_data_pool);

    if (g_rs.job_params.load_items != NULL)
        FREE(g_rs.job_params.load_items);
    if (g_rs.job_result.ptrs != NULL)
        FREE(g_rs.job_result.ptrs);

    log_print(LOG_TEXT, "res-mgr released.");
}
示例#6
0
void wld_destroy_section(struct wld_section* s)
{
    hashtable_open_destroy(&s->vtable);
    arr_destroy(&s->vars);
}
示例#7
0
文件: avl.c 项目: wkennington/adt
static avl_error_t
avl_insert_intern (avl_t avl, void * key, void * data, int replace)
{
  arr_t stack;
  size_t size;
  avl_entry_t *curr, tmp;
  int ret;

  /* Create a stack for saving the path */
  stack = arr_init ();
  if (stack == NULL)
    return AVL_MALLOC_FAILED;

  /* Iterate down the the insertion point and update the balance */
  curr = &avl->root;
  while (*curr != NULL)
    {
      /* Insert the node into the backlog */
      arr_insert_back (stack, curr);

      /* Determine the correct traveral direction */
      ret = avl->compare (key, (*curr)->key);
      if (ret == 0)
	{
	  arr_destroy (stack);
	  if (replace)
	    {
	      (*curr)->data = data;
	      return AVL_OK;
	    }
	  else
	    return AVL_KEY_EXISTS;
	}
      else if (ret < 0)
	{
	  (*curr)->balance--;
	  curr = &(*curr)->left;
	}
      else
	{
	  (*curr)->balance++;
	  curr = &(*curr)->right;
	}
    }

  /* Create the new entry */
  tmp = (avl_entry_t) malloc (sizeof (struct _avl_entry_t));
  if (tmp == NULL)
    return AVL_MALLOC_FAILED;
  tmp->left = NULL;
  tmp->right = NULL;
  tmp->balance = 0;
  tmp->key = key;
  tmp->data = data;

  /* Insert the entry */
  *curr = tmp;

  /* Rebalance the tree upward */
  while ((size = arr_size (stack)) > 0)
    {
      break;
    }

  /* Increase the Tree Size */
  avl->size++;

  /* Destroy the path stack */
  arr_destroy (stack);

  return AVL_OK;
}