int conn_pool_get_connection_count(ConnectionPool *cp)
{
	int count;
	count = 0;
	hash_walk(&cp->hash_array, _conn_count_walk, &count);
	return count;
}
void conn_pool_destroy(ConnectionPool *cp)
{
	pthread_mutex_lock(&cp->lock);
    hash_walk(&(cp->hash_array), coon_pool_close_connections, NULL);
	hash_destroy(&(cp->hash_array));
	pthread_mutex_unlock(&cp->lock);

	pthread_mutex_destroy(&cp->lock);
}
Example #3
0
static void iniSortItems(IniContext *pContext)
{
    if (pContext->global.count > 1)
    {
        qsort(pContext->global.items, pContext->global.count, \
              sizeof(IniItem), iniCompareByItemName);
    }

    hash_walk(&pContext->sections, iniSortHashData, NULL);
}
Example #4
0
int powaur_list_aur(void)
{
    struct pw_hashdb *hashdb = build_hashdb();
    if (!hashdb) {
        pw_fprintf(PW_LOG_ERROR, stderr, "Failed to build hashdb!\n");
        return -1;
    }

    hash_walk(hashdb->aur, pkgpair_print_color);
    hashdb_free(hashdb);
    return 0;
}
Example #5
0
void iniFreeContext(IniContext *pContext)
{
    if (pContext == NULL)
    {
        return;
    }

    if (pContext->global.items != NULL)
    {
        free(pContext->global.items);
        memset(&pContext->global, 0, sizeof(IniSection));
    }

    hash_walk(&pContext->sections, iniFreeHashData, NULL);
    hash_destroy(&pContext->sections);
}
Example #6
0
static result_t pickle__test2_read(void)
{
  result_t err;
  hash_t  *d;

  printf("test: create hash\n");

  err = hash_create(NULL,
                    0,
                    NULL,
                    NULL,
                    cheese_key_destroy,
                    cheese_value_destroy,
                   &d);
  if (err)
    goto Failure;

  printf("test: unpickle\n");

  err = pickle_unpickle(FILENAME,
                        d,
                       &pickle_writer_hash,
                       &unformat_cheese_methods,
                        NULL);
  if (err)
    goto Failure;

  printf("test: iterate\n");

  hash_walk(d, my_walk_fn, NULL);

  printf("test: destroy hash\n");

  hash_destroy(d);

  return result_TEST_PASSED;


Failure:

  printf("\n\n*** Error %x\n", err);

  return result_TEST_FAILED;
}
Example #7
0
void iniPrintItems(IniContext *pContext)
{
    IniItem *pItem;
    IniItem *pItemEnd;
    int i;

    printf("global section, item count: %d\n", pContext->global.count);
    if (pContext->global.count > 0)
    {
        i = 0;
        pItemEnd = pContext->global.items + pContext->global.count;
        for (pItem=pContext->global.items; pItem<pItemEnd; pItem++)
        {
            printf("%d. %s=%s\n", ++i, pItem->name, pItem->value);
        }
    }
    printf("\n");

    hash_walk(&pContext->sections, iniPrintHashData, NULL);
}
Example #8
0
error filenamedb_prune(filenamedb_t *db)
{
  hash_walk(db->hash, prune_cb, db);

  return error_OK;
}