Example #1
0
int main(int argc,char **argv) {
    apr_initialize();
    apr_pool_t *pool;
    apr_pool_create(&pool,NULL);
    apr_status_t st;

    apr_hash_t *ht;
    ht=apr_hash_make(pool);
    char *key;
    char *value;

    key="laomeng";
    value="*****@*****.**";
    apr_hash_set(ht,key,strlen(key),value);
    key="laozhang";
    value="*****@*****.**";
    apr_hash_set(ht,key,strlen(key),value);
    
    char *getvalue=apr_hash_get(ht,key,strlen(key));
    printf("getvalue : %s\n",getvalue);
    printf("total items: %u\n",apr_hash_count(ht));

    apr_hash_set(ht,key,strlen(key),NULL);
    printf("total items: %u\n",apr_hash_count(ht));

    apr_hash_clear(ht);
    printf("total items: %u\n",apr_hash_count(ht));
    getvalue=apr_hash_get(ht,key,strlen(key));
    printf("getvalue : %s\n",getvalue);

    apr_pool_destroy(pool);
    apr_terminate();
    return 0;
}
Example #2
0
void txn_info_destroy(txn_info_t *info) {
    for (int i = 0; i < info->sz_rids; i++) {
        free(info->rids[i]);
    }
    free(info->rids);
    apr_thread_mutex_destroy(info->mx);
    apr_hash_clear(info->ht_ginfo);
    apr_pool_destroy(info->mp);
    free(info);
}
static void globals_clear(void)
{
	/* Clear the hashes for the configuration of the profiles and the hash for the
	 * profile itself.
	 */
	if (globals.profiles != NULL) {
		apr_hash_index_t *hi;

		for (hi = apr_hash_first(NULL, globals.profiles); hi; hi = apr_hash_next(hi)) {
			const char *k;
			const void *key;
			ast_mrcp_profile_t *v;
			void *val;

			apr_hash_this(hi, &key, NULL, &val);

			k = (const char *)key;
			v = (ast_mrcp_profile_t *)val;

			if (v != NULL) {
				ast_log(LOG_DEBUG, "Clearing profile config for %s\n", k);
				v->name = NULL;
				v->version = NULL;
				v->jsgf_mime_type = NULL;
				v->gsl_mime_type = NULL;
				v->srgs_xml_mime_type = NULL;
				v->srgs_mime_type = NULL;
				apr_hash_clear(v->cfg);
				v->cfg = NULL;
			}

			k = NULL;
			v = NULL;
		}

		apr_hash_clear(globals.profiles);
	}

	if (globals.apps != NULL) {
		apr_hash_clear(globals.apps);
	}
}
Example #4
0
void detach_txn_info(txn_info_t *tinfo) {
    apr_thread_mutex_lock(mx_txn_info_);
    apr_hash_set(ht_txn_info_, &tinfo->tid, sizeof(txnid_t), NULL);
    apr_thread_mutex_unlock(mx_txn_info_);

    apr_hash_index_t *hi = NULL;
    for (hi = apr_hash_first(tinfo->mp, tinfo->ht_ginfo);
        hi; hi = apr_hash_next(hi)) {
        groupid_t *gid;
        group_info_t *ginfo = NULL;
        apr_hash_this(hi, (const void**)&gid, NULL, (void**)&ginfo);
        group_info_destroy(ginfo);
    }
    apr_hash_clear(tinfo->ht_ginfo);
    txn_info_destroy(tinfo);
}
Example #5
0
void UmcFramework::DestroyScenarios()
{
	UmcScenario* pScenario;
	void* pVal;
	apr_hash_index_t* it = apr_hash_first(m_pPool,m_pScenarioTable);
	for(; it; it = apr_hash_next(it)) 
	{
		apr_hash_this(it,NULL,NULL,&pVal);
		pScenario = (UmcScenario*) pVal;
		if(pScenario)
		{
			pScenario->Destroy();
			delete pScenario;
		}
	}
	apr_hash_clear(m_pScenarioTable);
}
Example #6
0
static void hash_clear(abts_case *tc, void *data)
{
    apr_hash_t *h;
    int i, *e;

    h = apr_hash_make(p);
    ABTS_PTR_NOTNULL(tc, h);

    for (i = 1; i <= 10; i++) {
        e = apr_palloc(p, sizeof(int));
        *e = i;
        apr_hash_set(h, e, sizeof(*e), e);
    }
    apr_hash_clear(h);
    i = apr_hash_count(h);
    ABTS_INT_EQUAL(tc, 0, i);
}
Example #7
0
/** Destroy registered engines and the factory */
MRCP_DECLARE(apt_bool_t) mrcp_engine_factory_destroy(mrcp_engine_factory_t *factory)
{
	mrcp_engine_t *engine;
	apr_hash_index_t *it;
	void *val;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Destroy MRCP Engines");
	it=apr_hash_first(factory->pool,factory->engines);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		engine = val;
		if(engine) {
			mrcp_engine_virtual_destroy(engine);
		}
	}
	apr_hash_clear(factory->engines);
	return TRUE;
}
/** Unload loaded plugins */
MRCP_DECLARE(apt_bool_t) mrcp_engine_loader_plugins_unload(mrcp_engine_loader_t *loader)
{
	apr_hash_index_t *it;
	void *val;
	apr_dso_handle_t *plugin;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Unload Plugins");
	it=apr_hash_first(loader->pool,loader->plugins);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		plugin = val;
		if(plugin) {
			apr_dso_unload(plugin);
		}
	}
	apr_hash_clear(loader->plugins);
	return TRUE;
}
svn_error_t *
svn_hash__clear(apr_hash_t *hash, apr_pool_t *pool)
{
#if APR_VERSION_AT_LEAST(1, 3, 0)
  apr_hash_clear(hash);
#else
  apr_hash_index_t *hi;
  const void *key;
  apr_ssize_t klen;

  for (hi = apr_hash_first(pool, hash); hi; hi = apr_hash_next(hi))
    {
      apr_hash_this(hi, &key, &klen, NULL);
      apr_hash_set(hash, key, klen, NULL);
    }
#endif
  return SVN_NO_ERROR;
}
/**
 * Clear the session cache, release the session pool
 */
void CALLBACK on_disconnect_handler(
    void *data, const WebSocketServer *server) {

    // if the threads wake up during disconnect, this tells 
    // them to go back to sleep.
    trans->client_connected = 0;

    request_rec *r = server->request(server);
    osrfLogInfo(OSRF_LOG_MARK, "WS disconnect from %s", get_client_ip(r)); 

    // Clear any lingering session data
    // NOTE: we could apr_pool_destroy the stateful_session_pool to truly free
    // the memory, but since there is a limit to the size of the pool
    // (max_concurrent_sessions), the memory cannot grow unbounded, 
    // so there's no need.
    apr_hash_clear(trans->stateful_session_cache);
    apr_pool_clear(trans->stateful_session_pool);
}
Example #11
0
void _rss_clear_check_table(data_service_fn_t *ds, apr_hash_t *table, apr_pool_t *mpool)
{
    apr_hash_index_t *hi;
    rss_check_entry_t *entry;
    const void *rid;
    apr_ssize_t klen;

    for (hi = apr_hash_first(NULL, table); hi != NULL; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, &rid, &klen, (void **)&entry);
        apr_hash_set(table, rid, klen, NULL);

        ds_inquire_destroy(ds, entry->space);
        free(entry->ds_key);
        free(entry->rid_key);
        free(entry);
    }

    apr_hash_clear(table);
}
Example #12
0
void DestroyAPRGlobalStorage (APRGlobalStorage *storage_p)
{
	if (storage_p)
		{
			if (storage_p -> ags_entries_p)
				{
					unsigned char *key_s = NULL;
					apr_ssize_t keylen = 0;
					void *value_p = NULL;
					apr_hash_index_t *index_p =	apr_hash_first (storage_p -> ags_pool_p, storage_p -> ags_entries_p);

					while (index_p)
						{
							apr_hash_this (index_p, (const void **) &key_s, &keylen, (void **) &value_p);

							storage_p -> ags_free_key_and_value_fn (key_s, value_p);

							index_p = apr_hash_next (index_p);
						}

					apr_hash_clear (storage_p -> ags_entries_p);
				}

			storage_p -> ags_pool_p = NULL;

			if (storage_p -> ags_mutex_p)
				{
					apr_global_mutex_destroy (storage_p -> ags_mutex_p);
					storage_p -> ags_mutex_p = NULL;
				}

			if (storage_p -> ags_socache_instance_p)
				{
					storage_p -> ags_socache_provider_p -> destroy (storage_p -> ags_socache_instance_p, storage_p -> ags_server_p);
				}

			if (storage_p -> ags_largest_entry_memory_id)
				{
					FreeSharedMemory (storage_p -> ags_largest_entry_memory_id);
				}
		}
}
Example #13
0
void destroy_hportal_context(portal_context_t *hpc)
{
    apr_hash_index_t *hi;
    host_portal_t *hp;
    void *val;

    for (hi=apr_hash_first(hpc->pool, hpc->table); hi != NULL; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, NULL, NULL, &val);
        hp = (host_portal_t *)val;
        apr_hash_set(hpc->table, hp->skey, APR_HASH_KEY_STRING, NULL);
        destroy_hportal(hp);
    }

    apr_thread_mutex_destroy(hpc->lock);

    apr_hash_clear(hpc->table);
    apr_pool_destroy(hpc->pool);

    free(hpc);

    return;
}
Example #14
0
File: apr.c Project: fd00/borghen
BorghenBoolean borghen_backend_destroy(BorghenObject hash)
{
  apr_hash_clear(hash);
  return TRUE;
}
Example #15
0
void controller_destroy() {
    apr_hash_clear(ht_txn_info_);
    apr_thread_mutex_destroy(mx_txn_info_);
    apr_pool_destroy(mp_txn_info_);
}