本文整理汇总了C++中dict_free函数的典型用法代码示例。如果您正苦于以下问题:C++ dict_free函数的具体用法?C++ dict_free怎么用?C++ dict_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dict_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: hyph_done
void hyph_done(void)
{
if (hwdict)
dict_free(hwdict);
if (hydict)
dict_free(hydict);
if (hcodedict)
dict_free(hcodedict);
}
开发者ID:litcave,项目名称:neatroff,代码行数:9,代码来源:hyph.c
示例2: conf_free
void conf_free(conf_t * self)
{
assert(self != NULL);
free(self->post_pkgadd);
list_free(self->repositories_hierarchy, free);
dict_free(self->favourite_repositories, NULL);
dict_free(self->locked_versions, free);
aliases_free(self->aliases);
dict_free(self->pkgmk_confs, free);
free(self);
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:11,代码来源:conf.c
示例3: megahal_reply
static int megahal_reply(brain_t brain, list_t *input, list_t **output) {
dict_t *keywords;
list_t *current;
struct timespec start;
double surprise;
double max_surprise;
int ret;
*output = NULL;
ret = megahal_keywords(brain, input, &keywords);
if (ret) return ret;
ret = megahal_generate(brain, NULL, output);
if (ret) {
dict_free(&keywords);
return ret;
}
if (!list_equal(input, *output))
list_free(output);
ret = clock_gettime(CLOCK_MONOTONIC, &start);
if (ret) {
ret = -ECLOCK;
goto fail;
}
max_surprise = -1.0;
do {
ret = megahal_generate(brain, keywords, ¤t);
if (ret) goto fail;
ret = megahal_evaluate(brain, keywords, current, &surprise);
if (ret) goto fail;
if (surprise > max_surprise && !list_equal(input, current)) {
max_surprise = surprise;
list_free(output);
*output = current;
} else {
list_free(¤t);
}
} while(!megahal_timeout(start));
dict_free(&keywords);
return OK;
fail:
list_free(output);
dict_free(&keywords);
return ret;
}
开发者ID:lp0,项目名称:sqlhal,代码行数:54,代码来源:megahal.c
示例4: main
int
main(int argc, char *argv[])
{
bin_mdef_t *mdef;
dict_t *dict;
cmd_ln_t *config;
int i;
char buf[100];
TEST_ASSERT(config = cmd_ln_init(NULL, NULL, FALSE,
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
"-fdict", MODELDIR "/en-us/en-us/noisedict",
NULL));
/* Test dictionary in standard fashion. */
TEST_ASSERT(mdef = bin_mdef_read(NULL, MODELDIR "/en-us/en-us/mdef"));
TEST_ASSERT(dict = dict_init(config, mdef, NULL));
printf("Word ID (CARNEGIE) = %d\n",
dict_wordid(dict, "CARNEGIE"));
printf("Word ID (ASDFASFASSD) = %d\n",
dict_wordid(dict, "ASDFASFASSD"));
TEST_EQUAL(0, dict_write(dict, "_cmu07a.dic", NULL));
TEST_EQUAL(0, system("diff -uw " MODELDIR "/en-us/cmudict-en-us.dict _cmu07a.dic"));
dict_free(dict);
bin_mdef_free(mdef);
/* Now test an empty dictionary. */
TEST_ASSERT(dict = dict_init(NULL, NULL, NULL));
printf("Word ID(<s>) = %d\n", dict_wordid(dict, "<s>"));
TEST_ASSERT(BAD_S3WID != dict_add_word(dict, "FOOBIE", NULL, 0));
TEST_ASSERT(BAD_S3WID != dict_add_word(dict, "BLETCH", NULL, 0));
printf("Word ID(FOOBIE) = %d\n", dict_wordid(dict, "FOOBIE"));
printf("Word ID(BLETCH) = %d\n", dict_wordid(dict, "BLETCH"));
TEST_ASSERT(dict_real_word(dict, dict_wordid(dict, "FOOBIE")));
TEST_ASSERT(dict_real_word(dict, dict_wordid(dict, "BLETCH")));
TEST_ASSERT(!dict_real_word(dict, dict_wordid(dict, "</s>")));
dict_free(dict);
/* Test to add 500k words. */
TEST_ASSERT(dict = dict_init(NULL, NULL, NULL));
for (i = 0; i < 500000; i++) {
sprintf(buf, "word_%d", i);
TEST_ASSERT(BAD_S3WID != dict_add_word(dict, buf, NULL, 0));
}
dict_free(dict);
cmd_ln_free_r(config);
return 0;
}
开发者ID:EvgenyAnisimoff,项目名称:pocketsphinx,代码行数:54,代码来源:test_dict.c
示例5: ini_free
extern void ini_free(ini_t * self)
{
unsigned i;
assert(self);
free(self->filepath);
for (i = 0; i < self->sections->length; i++)
dict_free(self->sections->elements[i]->value, free);
dict_free(self->sections, NULL);
free(self);
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:14,代码来源:ini.c
示例6: main
int main(int argc, char **argv) {
if(argc < 3) {
printf("usage: %s <encrypted_file> <dict1> [dict2] ...\n",argv[0]);
printf(" <encrypted_file> : encrypted password file, one per line\n");
printf(" <dict1> : dictionary to try for passwords for word 1\n");
printf(" [dict2] : additional dictionary to try for word 2\n");
printf(" : further dictionaries may be specified for more words\n");
return 0;
}
//check env variable for number of threads
int nthreads = 4;
char *nthreads_str = getenv("PASSCRACK_NUMTHREADS");
if(nthreads_str != NULL){
nthreads = atoi(nthreads_str);
}
// Load the passwords from a file
dict_t *passwords = dict_load(argv[1]);
printf("found %d passwords to crack\n",dict_get_word_count(passwords));
// Load all dictionaries of words
char **dict_files = &(argv[2]);
int dicts_len = argc-2;
dict_t **dicts = dict_load_dicts(dict_files, dicts_len);
// Show information on loaded dictionaries and compute the maximum
// length of the temporary buffer required to accomodate all
// possible passwords.
int buflen = 0;
for(int i=0; i<dicts_len; i++){
printf("dict %d: %d words\n",i,dict_get_word_count(dicts[i]));
buflen += dict_get_longest_word_length(dicts[i]);
}
char *buf = malloc(buflen * sizeof(char));
// Loop through each password in the password file and attempt to
// crack it.
int successes = 0;
for(int i=0; i<dict_get_word_count(passwords); i++){
// int i = 0;
char *encrypted = dict_get_word(passwords,i);
int success = try_crackpthread(encrypted, dicts, dicts_len, 0,
buf, buflen, 0,nthreads);
if(success == 1){
printf("%3d: SUCCES: %s <-- %s\n",i,encrypted,buf);
successes++;
}
else{
printf("%3d: FAILED: %s <-- %s\n",i,encrypted,"???");
}
}
printf("%d / %d passwords cracked\n",successes,dict_get_word_count(passwords));
// Free up memory and bail out
dict_free(passwords);
dict_free_dicts(dicts, dicts_len);
free(buf);
return 0;
}
开发者ID:alecwebb,项目名称:parallel-programming,代码行数:60,代码来源:pthread_passcrack.c
示例7: pdf_obj_delete
// Remove a single obj
void
pdf_obj_delete(pdf_obj *o)
{
if (!o)
return;
switch(o->t)
{
case eDict:
dict_free(o->value.d.dict);
break;
case eString:
case eHexString:
pdf_free(o->value.s.buf);
break;
case eName:
#ifndef HASHMAP
pdf_free(o->value.k);
#endif
break;
case eArray:
free_array(o);
break;
default:
break;
}
}
开发者ID:wongm168,项目名称:PegDF,代码行数:27,代码来源:pdfindex.c
示例8: tr_done
void tr_done(void)
{
int i;
for (i = 0; i < cdef_n; i++)
free(cdef_dst[i]);
dict_free(cmap);
}
开发者ID:litcave,项目名称:neatroff,代码行数:7,代码来源:tr.c
示例9: main
int main(int argc, char *argv[])
{
int ret = 0;
DICT_STR *my_dict_str = NULL;
ret = dict_init(&my_dict_str, argc, argv);
if (ERRNO_INIT == ret)
{
/* 如果没有初始化此结构体,说明用户执行 --help ,
* 并没有出错,所有此处不打印出错信息,直接返回。
* 而对于程序来说,--help或者错误的参数也是程序
* 没有正确执行的一部分,所以main仍返回错误。*/
if (NULL != my_dict_str)
printf("[DICT]%s: Initialization Failed.", __func__);
return ret;
}
ret = dict_exec(my_dict_str);
if (ERRNO_EXEC == ret)
printf("[DICT]%s: Execution Failed.", __func__);
dict_free(my_dict_str);
return ret;
}
开发者ID:leesheen,项目名称:dict-c,代码行数:26,代码来源:dict.c
示例10: dict_create
static dict_t *search_with_bm25_score(fts_t *fts, robj *query) {
int i, len, nonstopwords;
sds *terms;
/* dict of (title, fts_doc_score_t) */
dict_t *scores = dict_create();
dict_set_freecb(scores, dict_doc_score_free);
dict_t *queried_terms = dict_create();
terms = sds_tokenize(query->ptr, &len, &nonstopwords);
if (!terms) return scores;
for (i = 0; i < len; i++) {
sds term = terms[i];
list *idx;
if (sdslen(term) == 0) {
sdsfree(term);
continue;
}
if (dict_contains(queried_terms, term)) goto free_term;
dict_set(queried_terms, term, (void *)1);
idx = dict_get(fts->index, term);
if (!idx) goto free_term;
calculate_bm25(fts, idx, scores);
free_term:
sdsfree(term);
}
dict_free(queried_terms);
rr_free(terms);
return scores;
}
开发者ID:ncloudioj,项目名称:rhino-rox,代码行数:31,代码来源:rr_fts.c
示例11: main
///////////////////////
//test <test.dict>
int main(int argc, char * argv[]) {
struct mg_server * server;
//
if(argc < 2) {
printf("demo: %s <test.dict>\n", argv[0]);
exit(0);
}
//
dbox = dict_init();
dict_load(dbox, argv[1]);
//
server = mg_create_server(NULL, ev_handler);
//
mg_set_option(server, "listening_port", "8089");
//
for(;;) {
mg_poll_server(server, 1000);
}
//
mg_destroy_server(&server);
//
dict_free(dbox);
//
return 0;
}
开发者ID:terminator123,项目名称:mg_test,代码行数:27,代码来源:dict.c
示例12: dict_db_close
static void dict_db_close(DICT *dict)
{
DICT_DB *dict_db = (DICT_DB *) dict;
#if DB_VERSION_MAJOR > 1
if (dict_db->cursor)
dict_db->cursor->c_close(dict_db->cursor);
#endif
if (DICT_DB_SYNC(dict_db->db, 0) < 0)
msg_fatal("flush database %s: %m", dict_db->dict.name);
/*
* With some Berkeley DB implementations, close fails with a bogus ENOENT
* error, while it reports no errors with put+sync, no errors with
* del+sync, and no errors with the sync operation just before this
* comment. This happens in programs that never fork and that never share
* the database with other processes. The bogus close error has been
* reported for programs that use the first/next iterator. Instead of
* making Postfix look bad because it reports errors that other programs
* ignore, I'm going to report the bogus error as a non-error.
*/
if (DICT_DB_CLOSE(dict_db->db) < 0)
msg_info("close database %s: %m (possible Berkeley DB bug)",
dict_db->dict.name);
if (dict_db->key_buf)
vstring_free(dict_db->key_buf);
if (dict_db->val_buf)
vstring_free(dict_db->val_buf);
if (dict->fold_buf)
vstring_free(dict->fold_buf);
dict_free(dict);
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:32,代码来源:dict_db.c
示例13: testDictErrorHandling
void testDictErrorHandling() {
struct dict *d = NULL;
int e = dict_set(d, "hallo", "1");
assert(e == -1);
e = dict_del(d, "hallo");
assert(e == -1);
e = dict_has(d, "halo");
assert(e == 0);
const char *item = dict_get(d, "hallo");
assert(item == NULL);
d = dict_create();
dict_set(d, "hallo", "1");
dict_set(d, "hallo2", "1");
dict_set(d, "hallo3", "2");
e = dict_del(d, "halo");
assert(e == -1);
item = dict_get(d, "halo");
assert(item == NULL);
dict_free(d);
}
开发者ID:hyrise,项目名称:dispatcher,代码行数:28,代码来源:dict_test.c
示例14: testDict
void testDict() {
struct dict *d = dict_create(NULL);
dict_set(d, "name", "drmaa2");
dict_set(d, "language", "c");
dict_set(d, "version", "2");
dict_set(d, "age", "2 weeks");
assert(dict_has(d, "language") != 0);
dict_del(d, "age");
dict_del(d, "language");
assert(dict_has(d, "version") != 0);
dict_del(d, "name");
dict_set(d, "version", "3");
const char *v = dict_get(d, "version");
assert(strcmp(v, "3") == 0);
dict_del(d, "version");
dict_set(d, "new_version", "4");
assert(dict_has(d, "version") == 0);
assert(dict_has(d, "new_version") != 0);
dict_free(d);
}
开发者ID:hyrise,项目名称:dispatcher,代码行数:26,代码来源:dict_test.c
示例15: test_readelements
/* Test to insert a large number of elements in the dict. */
static void test_readelements(const char *fname)
{
DICT *dict;
char buf[80];
FILE *fp;
void *val;
const char **keys;
int i;
/* initialize */
dict=dict_new();
/* read file and insert all entries */
fp=fopen(fname,"r");
assert(fp!=NULL);
while (fgets(buf,sizeof(buf),fp)!=NULL)
{
/* strip newline */
buf[strlen(buf)-1]='\0';
dict_put(dict,buf,&buf);
}
fclose(fp);
/* loop over dictionary contents */
keys=dict_keys(dict);
for (i=0;keys[i]!=NULL;i++)
{
val=dict_get(dict,keys[i]);
assert(val==buf);
}
/* free stuff */
dict_free(dict);
free(keys);
}
开发者ID:silkentrance,项目名称:nss-pam-ldap,代码行数:32,代码来源:test_dict.c
示例16: free_mainconfig
/*
* Free the configuration. Called only when the server is exiting.
*/
int free_mainconfig(void)
{
cached_config_t *cc, *next;
virtual_servers_free(0);
/*
* Clean up the configuration data
* structures.
*/
clients_free(NULL);
realms_free();
listen_free(&mainconfig.listen);
/*
* Free all of the cached configurations.
*/
for (cc = cs_cache; cc != NULL; cc = next) {
next = cc->next;
cf_file_free(cc->cs);
free(cc);
}
dict_free();
return 0;
}
开发者ID:Gejove,项目名称:freeradius-server,代码行数:30,代码来源:mainconfig.c
示例17: dict2pid_free
int
dict2pid_free(dict2pid_t * d2p)
{
if (d2p == NULL)
return 0;
if (--d2p->refcount > 0)
return d2p->refcount;
if (d2p->ldiph_lc)
ckd_free_3d((void ***) d2p->ldiph_lc);
if (d2p->lrdiph_rc)
ckd_free_3d((void ***) d2p->lrdiph_rc);
if (d2p->rssid)
free_compress_map(d2p->rssid, bin_mdef_n_ciphone(d2p->mdef));
if (d2p->lrssid)
free_compress_map(d2p->lrssid, bin_mdef_n_ciphone(d2p->mdef));
bin_mdef_free(d2p->mdef);
dict_free(d2p->dict);
ckd_free(d2p);
return 0;
}
开发者ID:10v,项目名称:cmusphinx,代码行数:25,代码来源:dict2pid.c
示例18: case_dict_iter
void
case_dict_iter()
{
struct dict *dict = dict();
char *key1 = "key1"; size_t len1 = 4;
char *key2 = "key2"; size_t len2 = 4;
char *key3 = "key3"; size_t len3 = 4;
char *key4 = "key4"; size_t len4 = 4;
char *key5 = "key5"; size_t len5 = 4;
char *key6 = "key6"; size_t len6 = 4;
assert(dict_set(dict, key1, len1, "val1") == DICT_OK);
assert(dict_set(dict, key2, len2, "val2") == DICT_OK);
assert(dict_set(dict, key3, len3, "val3") == DICT_OK);
assert(dict_set(dict, key4, len4, "val4") == DICT_OK);
assert(dict_set(dict, key5, len5, "val5") == DICT_OK);
assert(dict_set(dict, key6, len6, "val6") == DICT_OK);
struct dict_iter *iter = dict_iter(dict);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) != NULL);
assert(dict_iter_next(iter) == NULL);
dict_iter_free(iter);
dict_free(dict);
}
开发者ID:codemaniac,项目名称:Daily-C-Snip,代码行数:29,代码来源:dict_test.c
示例19: assert
dict_t *ports_dict_init(list_t * ports_list, list_t * packages, conf_t * conf)
{
dict_t *self, *pkgmk_confs_exploded;
port_t *port, *found, *package;
unsigned i;
int cmp;
char *locked_version, *pkgmk_conf;
assert(ports_list != NULL && packages != NULL && conf != NULL);
pkgmk_confs_exploded = pkgmk_confs_explode(conf->pkgmk_confs,
ports_list);
self = dict_new();
for (i = 0; i < ports_list->length; i++) {
port = list_get(ports_list, i);
if ((pkgmk_conf = dict_get(pkgmk_confs_exploded, port->name)) !=
NULL)
port->pkgmk_conf = xstrdup(pkgmk_conf);
if ((locked_version =
dict_get(conf->locked_versions, port->name))) {
if (!strcmp(port->version, locked_version))
dict_add(self, port->name, port);
} else if (locked_version == NULL &&
(found = dict_get(conf->favourite_repositories,
port->name)) != NULL) {
if (strcmp(found->repository->name,
port->repository->name) == 0)
dict_add(self, port->name, port);
} else if (!locked_version
&& !(found = dict_get(self, port->name)))
dict_add(self, port->name, port);
else if (!locked_version && port->repository->priority >
found->repository->priority)
dict_add(self, port->name, port);
else if (!locked_version && port->repository->priority ==
found->repository->priority &&
strverscmp(port->version, found->version) > 0)
dict_add(self, port->name, port);
}
for (i = 0; i < packages->length; i++) {
package = list_get(packages, i);
if (!(port = dict_get(self, package->name))) {
dict_add(self, package->name, package);
continue;
}
if ((cmp = strverscmp(port->version, package->version)) > 0)
port->status = PRT_OUTDATED;
else if (cmp < 0)
port->status = PRT_DIFF;
else
port->status = PRT_INSTALLED;
}
dict_free(pkgmk_confs_exploded, free);
return self;
}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:60,代码来源:port.c
示例20: ddb_update
int
ddb_update (const dict_t *config,
const char *startup,
const char *name,
compat_flags_t flags)
{
int result = RET_OK;
const char *disc_db = dict_lookup (config, CONFIG_DISC_DATABASE_FILE);
dict_t *list = dict_restore (NULL, disc_db);
if (list != NULL)
{
char tmp[500];
compat_flags_t dummy;
result = ddb_lookup (config, startup, tmp, &dummy);
if (result != RET_DDB_INCOMPATIBLE)
{ /* do not overwrite entries, marked as incompatible */
sprintf (tmp, "%s;0x%02x", name, flags);
(void) dict_put (list, startup, tmp);
result = dict_store (list, disc_db);
}
dict_free (list), list = NULL;
}
else
result = RET_NO_DISC_DB;
return (result);
}
开发者ID:dyzz,项目名称:hdldumb,代码行数:27,代码来源:common.c
注:本文中的dict_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论