示例#1
0
文件: module.c 项目: howard5888/wineT
/******************************************************************
 *		module_remove
 *
 */
BOOL module_remove(struct process* pcs, struct module* module)
{
    struct module**     p;

    TRACE("%s (%p)\n", module->module.ModuleName, module);
    hash_table_destroy(&module->ht_symbols);
    hash_table_destroy(&module->ht_types);
    HeapFree(GetProcessHeap(), 0, (char*)module->sources);
    HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
    pool_destroy(&module->pool);
    /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
     * so do we
     */
    for (p = &pcs->lmodules; *p; p = &(*p)->next)
    {
        if (*p == module)
        {
            *p = module->next;
            HeapFree(GetProcessHeap(), 0, module);
            return TRUE;
        }
    }
    FIXME("This shouldn't happen\n");
    return FALSE;
}
示例#2
0
/******************************************************************
 *		module_remove
 *
 */
BOOL module_remove(struct process* pcs, struct module* module)
{
    struct module_format*modfmt;
    struct module**     p;
    unsigned            i;

    TRACE("%s (%p)\n", debugstr_w(module->module.ModuleName), module);

    for (i = 0; i < DFI_LAST; i++)
    {
        if ((modfmt = module->format_info[i]) && modfmt->remove)
            modfmt->remove(pcs, module->format_info[i]);
    }
    hash_table_destroy(&module->ht_symbols);
    hash_table_destroy(&module->ht_types);
    wine_rb_destroy(&module->sources_offsets_tree, NULL, NULL);
    HeapFree(GetProcessHeap(), 0, module->sources);
    HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
    pool_destroy(&module->pool);
    /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
     * so do we
     */
    for (p = &pcs->lmodules; *p; p = &(*p)->next)
    {
        if (*p == module)
        {
            *p = module->next;
            HeapFree(GetProcessHeap(), 0, module);
            return TRUE;
        }
    }
    FIXME("This shouldn't happen\n");
    return FALSE;
}
示例#3
0
/* <BASE HREF="http://msdn.microsoft.com/workshop/author/dhtml/reference/"/>
   <a href=""> text </a>
   <img src="" >

   return:buffer:Url\nUrl\...\n
*/
int extract_interesting_tag_attr(char *html_content, int content_len,
                                 char *interesting_tag, char *interesting_tag_attr,
                                 buffer_t *interesting_tag_attr_buf_p, int count)
{
  struct interesting_tag_attr maparg;
  struct hash_table * interesting_tag_ht, *interesting_attr_ht;

  if (count == 0)
    return -1;

  interesting_tag_ht = make_nocase_string_hash_table(1);
  interesting_attr_ht = make_nocase_string_hash_table(1);
  hash_table_put(interesting_tag_ht, interesting_tag, interesting_tag_attr);
  hash_table_put(interesting_attr_ht, interesting_tag_attr, interesting_tag);

  maparg.interesting_tag_attr = interesting_tag_attr;
  maparg.interesting_tag_attr_buf_p = interesting_tag_attr_buf_p;
  maparg.is_ok = 0;
  maparg.count = count;

  map_html_tags(html_content, content_len, extract_interesting_tag_attr_mapfun, &maparg, MHT_TRIM_VALUES, interesting_tag_ht, interesting_attr_ht);

  if (interesting_tag_ht)
    hash_table_destroy(interesting_tag_ht);

  if (interesting_attr_ht)
    hash_table_destroy(interesting_attr_ht);

  if (maparg.is_ok)
    return 0;
  else
    return -1;
}
示例#4
0
/* Cleanup the data structures associated with recursive retrieving
   (the variables above).  */
void
recursive_cleanup (void)
{
  if (undesirable_urls)
    {
      string_set_free (undesirable_urls);
      undesirable_urls = NULL;
    }
  if (dl_file_url_map)
    {
      free_keys_and_values (dl_file_url_map);
      hash_table_destroy (dl_file_url_map);
      dl_file_url_map = NULL;
    }
  if (dl_url_file_map)
    {
      free_keys_and_values (dl_url_file_map);
      hash_table_destroy (dl_url_file_map);
      dl_url_file_map = NULL;
    }
  undesirable_urls = NULL;
  free_vec (forbidden);
  forbidden = NULL;
  slist_free (downloaded_html_files);
  downloaded_html_files = NULL;
  FREE_MAYBE (base_dir);
  FREE_MAYBE (robots_host);
  first_time = 1;
}
示例#5
0
void extract_text_free(struct hash_table *spec_tag_ht, struct hash_table * tag_attr_ht)
{
  if (spec_tag_ht)
    hash_table_destroy(spec_tag_ht);

  if (tag_attr_ht)
    hash_table_destroy(tag_attr_ht);
}
示例#6
0
void
cleanup_html_url (void)
{
  /* Destroy the hash tables.  The hash table keys and values are not
     allocated by this code, so we don't need to free them here.  */
  if (interesting_tags)
    hash_table_destroy (interesting_tags);
  if (interesting_attributes)
    hash_table_destroy (interesting_attributes);
}
void mailbox_list_index_reset(struct mailbox_list_index *ilist)
{
	hash_table_destroy(&ilist->mailbox_names);
	hash_table_destroy(&ilist->mailbox_hash);
	pool_unref(&ilist->mailbox_pool);

	ilist->mailbox_tree = NULL;
	ilist->highest_name_id = 0;
	ilist->sync_log_file_seq = 0;
	ilist->sync_log_file_offset = 0;

	mailbox_list_index_init_pool(ilist);
}
示例#8
0
文件: module.c 项目: howard5888/wineT
/******************************************************************
 *		module_reset_debug_info
 * Removes any debug information linked to a given module.
 */
void module_reset_debug_info(struct module* module)
{
    module->sortlist_valid = TRUE;
    module->addr_sorttab = NULL;
    hash_table_destroy(&module->ht_symbols);
    module->ht_symbols.num_buckets = 0;
    module->ht_symbols.buckets = NULL;
    hash_table_destroy(&module->ht_types);
    module->ht_types.num_buckets = 0;
    module->ht_types.buckets = NULL;
    module->vtypes.num_elts = 0;
    hash_table_destroy(&module->ht_symbols);
    module->sources_used = module->sources_alloc = 0;
    module->sources = NULL;
}
示例#9
0
文件: main.c 项目: ox/hash_table
int main(int argc, char ** argv) {
	int i;
  struct hash_table * table = hash_table_new(1);

  struct client * cli = malloc(sizeof(struct client));
  cli->name = "foo bar"; cli->credit = 5;
  hash_table_store(table, cli->name, cli);

  cli = malloc(sizeof(struct client));
  cli->name = "far bar"; cli->credit = 6;
  hash_table_store(table, cli->name, cli);

  cli = hash_table_delete(table, "foo bar"); /* returns the deleted value */
  printf("deleting: %i, should be 1\n", cli != NULL);
  cli = hash_table_delete(table, "doesn't exist"); /* returns NULL */
  printf("deleting: %i, should be 1\n", cli == NULL);

  struct client * cl2 = hash_table_get(table, "far bar");
  printf("%s has %i money\n", cl2->name, cl2->credit);

	/* get all of the keys and list them */
	char ** keys = hash_table_get_all_keys(table);
	for (i = 0; i < table->population; i++) {
		printf("key: %s\n", keys[i]);
	}

	free(keys);
	free(cli);
	free(cl2);

  hash_table_destroy(table, free_fn);
  return 0;
}
示例#10
0
void db_passwd_file_unref(struct db_passwd_file **_db)
{
        struct db_passwd_file *db = *_db;
        struct db_passwd_file **p;
	struct hash_iterate_context *iter;
	char *path;
	struct passwd_file *file;

	*_db = NULL;
	i_assert(db->refcount >= 0);
	if (--db->refcount > 0)
		return;

	for (p = &passwd_files; *p != NULL; p = &(*p)->next) {
		if (*p == db) {
			*p = db->next;
			break;
		}
	}

	if (db->default_file != NULL)
		passwd_file_free(db->default_file);
	else {
		iter = hash_table_iterate_init(db->files);
		while (hash_table_iterate(iter, db->files, &path, &file))
			passwd_file_free(file);
		hash_table_iterate_deinit(&iter);
		hash_table_destroy(&db->files);
	}
	i_free(db->path);
	i_free(db);
}
示例#11
0
int main() {
	
	hash_table_t* people = hash_table_init(100);
	
	entry_t oliv = { "Pinon", "Olivier", "01 02 03 04", "Paris" };
	entry_t pa = { "Durand", "Pierre-Alexandre", "33 04 10", "Lyon" };

	printf("Does string equality work ? %d\n", eq_str(pa.name, "Durand"));

	hash_table_insert( people, &oliv );
	hash_table_insert( people, &pa );

	hash_table_print( people );

	list_t test = hash_table_find_by_name(people, "Durand");
	printf("%s\n   ", "Is M.Durand here ?");
	print_list(test);
	destroy_list(test);

	test = hash_table_find_by_surname(people, "Pierre-Alexandre");
	printf("%s\n   ", "Is Pierre-Alexandre here ?");
	print_list(test);
	destroy_list(test);

	printf("hash map test done\n");
	hash_table_print(people);

	hash_table_destroy( people );

	return 0;
};
示例#12
0
int main(int argc, char* argv[])
{
	int i = 0;
	int n = 10000;
	int ret_data = 0;
	HashTable* hash_table = hash_table_create(NULL, NULL, hash_int, 31);

	for(i = 0; i < n; i++)
	{
		assert(hash_table_length(hash_table) == i);
		assert(hash_table_insert(hash_table, (void*)i) == RET_OK);
		assert(hash_table_length(hash_table) == (i + 1));
		assert(hash_table_find(hash_table, cmp_int, (void*)i, (void**)&ret_data) == RET_OK);
		assert(ret_data == i);
	}

	for(i = 0; i < n; i++)
	{
		assert(hash_table_delete(hash_table, cmp_int, (void*)i) == RET_OK);
		assert(hash_table_length(hash_table) == (n - i -1));
		assert(hash_table_find(hash_table, cmp_int, (void*)i, (void**)&ret_data) != RET_OK);
	}
	
	hash_table_destroy(hash_table);

	return 0;
}
static void stats_top(const char *path, const char *sort_type)
{
	struct top_context ctx;

	memset(&ctx, 0, sizeof(ctx));
	ctx.path = path;
	ctx.fd = doveadm_connect(path);
	ctx.prev_pool = pool_alloconly_create("stats top", 1024*16);
	ctx.cur_pool = pool_alloconly_create("stats top", 1024*16);
	i_array_init(&ctx.lines, 128);
	hash_table_create(&ctx.sessions, default_pool, 0, str_hash, strcmp);
	net_set_nonblock(ctx.fd, FALSE);

	ctx.input = i_stream_create_fd(ctx.fd, (size_t)-1, TRUE);

	if (strstr(sort_type, "cpu") != NULL)
		ctx.lines_sort = sort_cpu;
	else
		ctx.lines_sort = sort_num;
	ctx.sort_type = sort_type;

	stats_top_start(&ctx);
	i_stream_destroy(&ctx.input);
	hash_table_destroy(&ctx.sessions);
	array_free(&ctx.lines);
	pool_unref(&ctx.prev_pool);
	pool_unref(&ctx.cur_pool);
	i_close_fd(&ctx.fd);
}
示例#14
0
文件: test-hash.c 项目: Raffprta/core
static void test_hash_random_pool(pool_t pool)
{
#define KEYMAX 100000
	HASH_TABLE(void *, void *) hash;
	unsigned int *keys;
	unsigned int i, key, keyidx, delidx;

	keys = i_new(unsigned int, KEYMAX); keyidx = 0;
	hash_table_create_direct(&hash, pool, 0);
	for (i = 0; i < KEYMAX; i++) {
		key = (rand() % KEYMAX) + 1;
		if (rand() % 5 > 0) {
			if (hash_table_lookup(hash, POINTER_CAST(key)) == NULL) {
				hash_table_insert(hash, POINTER_CAST(key),
						  POINTER_CAST(1));
				keys[keyidx++] = key;
			}
		} else if (keyidx > 0) {
			delidx = rand() % keyidx;
			hash_table_remove(hash, POINTER_CAST(keys[delidx]));
			memmove(&keys[delidx], &keys[delidx+1],
				(keyidx-delidx-1) * sizeof(*keys));
			keyidx--;
		}
	}
	for (i = 0; i < keyidx; i++)
		hash_table_remove(hash, POINTER_CAST(keys[i]));
	hash_table_destroy(&hash);
	i_free(keys);
}
示例#15
0
static void config_export_free(struct config_export_context *ctx)
{
	if (ctx->dup_parsers != NULL)
		config_filter_parsers_free(ctx->dup_parsers);
	hash_table_destroy(&ctx->keys);
	pool_unref(&ctx->pool);
}
示例#16
0
static void fts_filter_stopwords_destroy(struct fts_filter *filter)
{
	struct fts_filter_stopwords *sp = (struct fts_filter_stopwords *)filter;

	if (hash_table_is_created(sp->stopwords))
		hash_table_destroy(&sp->stopwords);
	pool_unref(&sp->pool);
}
示例#17
0
文件: cookies.c 项目: kmekler/symblog
void
cookies_cleanup (void)
{
  if (!cookies_hash_table)
    return;
  hash_table_map (cookies_hash_table, delete_cookie_chain_mapper, NULL);
  hash_table_destroy (cookies_hash_table);
  cookies_hash_table = NULL;
}
示例#18
0
void
downloaded_files_free (void)
{
  if (downloaded_files_hash)
    {
      hash_table_map (downloaded_files_hash, df_free_mapper, NULL);
      hash_table_destroy (downloaded_files_hash);
      downloaded_files_hash = NULL;
    }
}
示例#19
0
文件: dict.c 项目: lulujiang/segc
void
dict_deinit(void)
{
#ifdef AVLTREE
    avltree_destroy(root);
#else
    hash_table_destroy(root);
#endif
    root = NULL;
}
示例#20
0
void
res_cleanup (void)
{
    if (registered_specs)
    {
        hash_table_map (registered_specs, cleanup_hash_table_mapper, NULL);
        hash_table_destroy (registered_specs);
        registered_specs = NULL;
    }
}
示例#21
0
文件: host.c 项目: Red54/axtu
void
host_cleanup (void)
{
  if (host_name_addresses_map)
    {
      hash_table_map (host_name_addresses_map, host_cleanup_mapper, NULL);
      hash_table_destroy (host_name_addresses_map);
      host_name_addresses_map = NULL;
    }
}
示例#22
0
void sql_db_cache_deinit(struct sql_db_cache **_cache)
{
	struct sql_db_cache *cache = *_cache;

	*_cache = NULL;
	while (cache->unused_tail != NULL)
		sql_db_cache_free_tail(cache);
	hash_table_destroy(&cache->dbs);
	i_free(cache);
}
示例#23
0
void http_client_deinit(struct http_client **_client)
{
	struct http_client *client = *_client;
	struct http_client_request *req;
	struct http_client_host *host;
	struct http_client_peer *peer;

	*_client = NULL;

	/* destroy requests without calling callbacks */
	req = client->requests_list;
	while (req != NULL) {
		struct http_client_request *next_req = req->next;
		http_client_request_destroy(&req);
		req = next_req;
	}
	i_assert(client->requests_count == 0);

	/* free peers */
	while (client->peers_list != NULL) {
		peer = client->peers_list;
		http_client_peer_close(&peer);
	}
	hash_table_destroy(&client->peers);

	/* free hosts */
	while (client->hosts_list != NULL) {
		host = client->hosts_list;
		http_client_host_free(&host);
	}
	hash_table_destroy(&client->hosts);

	array_free(&client->delayed_failing_requests);
	if (client->to_failing_requests != NULL)
		timeout_remove(&client->to_failing_requests);

	connection_list_deinit(&client->conn_list);

	if (client->ssl_ctx != NULL)
		ssl_iostream_context_deinit(&client->ssl_ctx);
	pool_unref(&client->pool);
}
void auth_server_connection_deinit(struct auth_server_connection **_conn)
{
        struct auth_server_connection *conn = *_conn;

	*_conn = NULL;

	auth_server_connection_disconnect(conn);
	hash_table_destroy(&conn->requests);
	array_free(&conn->available_auth_mechs);
	pool_unref(&conn->pool);
}
示例#25
0
static void
init_interesting (void)
{
  /* Init the variables interesting_tags and interesting_attributes
     that are used by the HTML parser to know which tags and
     attributes we're interested in.  We initialize this only once,
     for performance reasons.

     Here we also make sure that what we put in interesting_tags
     matches the user's preferences as specified through --ignore-tags
     and --follow-tags.  */

  int i;
  interesting_tags = make_nocase_string_hash_table (countof (known_tags));

  /* First, add all the tags we know hot to handle, mapped to their
     respective entries in known_tags.  */
  for (i = 0; i < countof (known_tags); i++)
    hash_table_put (interesting_tags, known_tags[i].name, known_tags + i);

  /* Then remove the tags ignored through --ignore-tags.  */
  if (opt.ignore_tags)
    {
      char **ignored;
      for (ignored = opt.ignore_tags; *ignored; ignored++)
        hash_table_remove (interesting_tags, *ignored);
    }

  /* If --follow-tags is specified, use only those tags.  */
  if (opt.follow_tags)
    {
      /* Create a new table intersecting --follow-tags and known_tags,
         and use it as interesting_tags.  */
      struct hash_table *intersect = make_nocase_string_hash_table (0);
      char **followed;
      for (followed = opt.follow_tags; *followed; followed++)
        {
          struct known_tag *t = hash_table_get (interesting_tags, *followed);
          if (!t)
            continue;           /* ignore unknown --follow-tags entries. */
          hash_table_put (intersect, *followed, t);
        }
      hash_table_destroy (interesting_tags);
      interesting_tags = intersect;
    }

  /* Add the attributes we care about. */
  interesting_attributes = make_nocase_string_hash_table (10);
  for (i = 0; i < countof (additional_attributes); i++)
    hash_table_put (interesting_attributes, additional_attributes[i], "1");
  for (i = 0; i < countof (tag_url_attributes); i++)
    hash_table_put (interesting_attributes,
                    tag_url_attributes[i].attr_name, "1");
}
示例#26
0
/* Cleanup the data structures associated with recursive retrieving
   (the variables above).  */
void
convert_cleanup (void)
{
  if (dl_file_url_map)
    {
      free_keys_and_values (dl_file_url_map);
      hash_table_destroy (dl_file_url_map);
      dl_file_url_map = NULL;
    }
  if (dl_url_file_map)
    {
      free_keys_and_values (dl_url_file_map);
      hash_table_destroy (dl_url_file_map);
      dl_url_file_map = NULL;
    }
  if (downloaded_html_set)
    string_set_free (downloaded_html_set);
  slist_free (downloaded_html_list);
  downloaded_html_list = NULL;
}
示例#27
0
void indexer_queue_deinit(struct indexer_queue **_queue)
{
	struct indexer_queue *queue = *_queue;

	*_queue = NULL;

	i_assert(indexer_queue_is_empty(queue));

	hash_table_destroy(&queue->requests);
	i_free(queue);
}
示例#28
0
void maildir_keywords_deinit(struct maildir_keywords **_mk)
{
	struct maildir_keywords *mk = *_mk;

	*_mk = NULL;
	hash_table_destroy(&mk->hash);
	array_free(&mk->list);
	pool_unref(&mk->pool);
	i_free(mk->path);
	i_free(mk);
}
void mail_sessions_deinit(void)
{
	while (mail_sessions_head != NULL) {
		struct mail_session *session = mail_sessions_head;

		if (!session->disconnected)
			mail_session_unref(&session);
		mail_session_free(mail_sessions_head);
	}
	hash_table_destroy(&mail_sessions_hash);
}
示例#30
0
void http_client_deinit(struct http_client **_client)
{
	struct http_client *client = *_client;
	struct http_client_request *req, *const *req_idx;
	struct http_client_host *host;
	struct http_client_peer *peer;

	/* drop delayed failing requests */
	while (array_count(&client->delayed_failing_requests) > 0) {
		req_idx = array_idx(&client->delayed_failing_requests, 0);
		req = *req_idx;

		i_assert(req->refcount == 1);
		http_client_request_error_delayed(&req);
	}
	array_free(&client->delayed_failing_requests);

	if (client->to_failing_requests != NULL)
		timeout_remove(&client->to_failing_requests);

	/* free peers */
	while (client->peers_list != NULL) {
		peer = client->peers_list;
		http_client_peer_free(&peer);
	}
	hash_table_destroy(&client->peers);

	/* free hosts */
	while (client->hosts_list != NULL) {
		host = client->hosts_list;
		http_client_host_free(&host);
	}
	hash_table_destroy(&client->hosts);

	connection_list_deinit(&client->conn_list);

	if (client->ssl_ctx != NULL)
		ssl_iostream_context_deinit(&client->ssl_ctx);
	pool_unref(&client->pool);
	*_client = NULL;
}