void radius_acct_shutdown(void) { if (radius_mutex == NULL) /* haven't init'ed at all */ return ; mutex_lock(radius_mutex); run_thread = 0; mutex_unlock(radius_mutex); gwthread_join_every(proxy_thread); dict_destroy(radius_table); dict_destroy(session_table); dict_destroy(client_table); mutex_destroy(radius_mutex); octstr_destroy(our_host); octstr_destroy(remote_host); octstr_destroy(secret_nas); octstr_destroy(secret_radius); octstr_destroy(unified_prefix); info(0, "RADIUS: accounting proxy stopped."); }
void urltrans_destroy(URLTranslationList *trans) { list_destroy(trans->list, destroy_onetrans); dict_destroy(trans->names); dict_destroy(trans->dict); gw_free(trans); }
static void smsboxc_run(void *arg) { int fd; int port; gwlist_add_producer(flow_threads); gwthread_wakeup(MAIN_THREAD_ID); port = (int) *((long *)arg); fd = make_server_socket(port, NULL); /* XXX add interface_name if required */ if (fd < 0) { panic(0, "Could not open smsbox port %d", port); } /* * infinitely wait for new connections; * to shut down the system, SIGTERM is send and then * select drops with error, so we can check the status */ wait_for_connections(fd, run_smsbox, incoming_sms, smsbox_port_ssl); gwlist_remove_producer(smsbox_list); /* continue avalanche */ gwlist_remove_producer(outgoing_sms); /* all connections do the same, so that all must remove() before it * is completely over */ while(gwlist_wait_until_nonempty(smsbox_list) == 1) gwthread_sleep(1.0); /* close listen socket */ close(fd); gwthread_wakeup(sms_dequeue_thread); gwthread_join(sms_dequeue_thread); gwlist_destroy(smsbox_list, NULL); smsbox_list = NULL; gw_rwlock_destroy(smsbox_list_rwlock); smsbox_list_rwlock = NULL; /* destroy things related to smsbox routing */ dict_destroy(smsbox_by_id); smsbox_by_id = NULL; dict_destroy(smsbox_by_smsc); smsbox_by_smsc = NULL; dict_destroy(smsbox_by_receiver); smsbox_by_receiver = NULL; dict_destroy(smsbox_by_smsc_receiver); smsbox_by_smsc_receiver = NULL; gwlist_remove_producer(flow_threads); }
void cfg_destroy(Cfg *cfg) { if (cfg != NULL) { octstr_destroy(cfg->filename); dict_destroy(cfg->single_groups); dict_destroy(cfg->multi_groups); gw_free(cfg); } }
/* void cxml_node_free(CLOG_INFO* info, void * data) { CXMLNODE *node = (CXMLNODE*) data; */ void cxml_node_free(CLOG_INFO* info, CXMLNODE **node) { dnode_t *dn = NULL; if(NULL==node || NULL==*node) { return; } clog( info, CTRACE, "XML: xml_node_free(), free the attributes"); // free the attributes if(NULL!=(*node)->att) { if(!dict_isempty((*node)->att)) { for (dn = dict_first((*node)->att); dn; dn = dict_next((*node)->att, dn)) { char *key=(char*)dnode_getkey(dn); char *data=(char*)dnode_get(dn); if(NULL!=key) free(key); key=NULL; if(NULL!=data) free(data); data=NULL; } } dict_free_nodes((*node)->att); dict_destroy((*node)->att); (*node)->att=NULL; } clog( info, CTRACE, "XML: xml_node_free(), free the name"); // free the name if(NULL!=(*node)->name) cstring_free(&((*node)->name)); clog( info, CTRACE, "XML: xml_node_free(), free the data"); // free the data if(NULL!=(*node)->data) cstring_free(&((*node)->data)); clog( info, CTRACE, "XML: xml_node_free(), free the subs"); // free the children if(NULL!=(*node)->sub) { if(!dict_isempty((*node)->sub)) { for (dn = dict_first((*node)->sub); dn; dn = dict_next((*node)->sub, dn)) { char *key=(char*)dnode_getkey(dn); CXMLNODE *data=(CXMLNODE*)dnode_get(dn); if(NULL!=key) free(key); key=NULL; cxml_node_free(info, &data); } } dict_free_nodes((*node)->sub); dict_destroy((*node)->sub); (*node)->sub=NULL; } free((*node)); (*node)=NULL; node=NULL; }
int smpp_pdu_shutdown(void) { if (initialized == 0) return 0; initialized = 0; gwlist_destroy(tlvs, (void(*)(void*))smpp_tlv_destroy); tlvs = NULL; dict_destroy(tlvs_by_tag); dict_destroy(tlvs_by_name); tlvs_by_tag = tlvs_by_name = NULL; return 0; }
static void brunet_parse_reply(SMSCConn *conn, Msg *msg, int status, List *headers, Octstr *body) { if (status == HTTP_OK || status == HTTP_ACCEPTED) { Dict *param; Octstr *status; if ((param = brunet_parse_body(body)) != NULL && (status = dict_get(param, octstr_imm("Status"))) != NULL && octstr_case_compare(status, octstr_imm("0")) == 0) { Octstr *msg_id; /* pass the MessageId for this MT to the logging facility */ if ((msg_id = dict_get(param, octstr_imm("MessageId"))) != NULL) msg->sms.binfo = octstr_duplicate(msg_id); bb_smscconn_sent(conn, msg, NULL); } else { error(0, "HTTP[%s]: Message was malformed. SMSC response `%s'.", octstr_get_cstr(conn->id), octstr_get_cstr(body)); bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_MALFORMED, octstr_duplicate(body)); } dict_destroy(param); } else { error(0, "HTTP[%s]: Message was rejected. SMSC reponse `%s'.", octstr_get_cstr(conn->id), octstr_get_cstr(body)); bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_REJECTED, octstr_duplicate(body)); } }
static dict_t * make_seq_dict (int argc, char **argv) { char index[] = "4294967296"; // 1<<32 int i = 0; int ret = 0; dict_t *dict = dict_new (); if (!dict) return NULL; for (i = 0; i < argc; i++) { snprintf(index, sizeof(index), "%d", i); ret = dict_set_str (dict, index, argv[i]); if (ret == -1) break; } if (ret) { dict_destroy (dict); dict = NULL; } return dict; }
void ui_destroy(t_dict *dict_key) { extern t_command_line g_cmdl; free(g_cmdl.hostname); if (dict_key != NULL) dict_destroy(dict_key); }
/// Finalizer - releases all allocated memory for object. /// If object is a null pointer, no action occurs. /// @param[in] ca the object pointer void ca_destroy(ca_o ca) { hash_t *hash; if (!ca) { return; } if ((hash = ca->ca_group_hash)) { if (hash_count(hash)) { putil_warn("group destroyed with %d audits left", (int)hash_count(hash)); } hash_destroy(ca->ca_group_hash); ca->ca_group_hash = NULL; } ca_clear_pa(ca); dict_destroy(ca->ca_raw_pa_dict); putil_free(ca->ca_prog); putil_free(ca->ca_host); putil_free(ca->ca_recycled); putil_free(ca->ca_rwd); putil_free(ca->ca_pccode); putil_free(ca->ca_ccode); putil_free(ca->ca_pathcode); putil_free(ca->ca_subs); putil_free(ca->ca_freetext); putil_free(ca->ca_line); memset(ca, 0, sizeof(*ca)); putil_free(ca); }
/// Clear out the raw set and cooked sets. Destroy the entire /// cooked data structure but leave the raw one present though /// empty. This is the same as the initial (post-creation) state. /// @param[in] ca the object pointer void ca_clear_pa(ca_o ca) { dict_t *dict; dnode_t *dnp, *next; pa_o pa; if ((dict = ca->ca_raw_pa_dict)) { for (dnp = dict_first(dict); dnp;) { next = dict_next(dict, dnp); pa = (pa_o)dnode_getkey(dnp); dict_delete(dict, dnp); dnode_destroy(dnp); pa_destroy(pa); dnp = next; } } if ((dict = ca->ca_cooked_pa_dict)) { for (dnp = dict_first(dict); dnp;) { next = dict_next(dict, dnp); pa = (pa_o)dnode_getkey(dnp); dict_delete(dict, dnp); dnode_destroy(dnp); pa_destroy(pa); dnp = next; } dict_destroy(ca->ca_cooked_pa_dict); ca->ca_cooked_pa_dict = NULL; } }
int main(int ac, char **av, char **env) { t_cmd cmd; t_dict *envc; (void)ac; (void)av; signal(SIGINT, sig_handler); envc = envcpy(env); init_tokens(); interpret_command(envc, &cmd); dict_destroy(g_tokens); dict_destroy(envc); cmd_free(&cmd); return (0); }
/* Destroys AGR. */ static void agr_destroy (struct agr_proc *agr) { struct agr_var *iter, *next; subcase_destroy (&agr->sort); free (agr->break_vars); for (iter = agr->agr_vars; iter; iter = next) { next = iter->next; if (iter->function & FSTRING) { size_t n_args; size_t i; n_args = agr_func_tab[iter->function & FUNC].n_args; for (i = 0; i < n_args; i++) free (iter->arg[i].c); free (iter->string); } else if (iter->function == SD) moments1_destroy (iter->moments); dict_destroy_internal_var (iter->subject); dict_destroy_internal_var (iter->weight); free (iter); } if (agr->dict != NULL) dict_destroy (agr->dict); }
void history_free(history_t* past) { state_free(dict_lookup(past->states, "x")); state_free(dict_lookup(past->states, "y")); state_free(dict_lookup(past->states, "scalex")); state_free(dict_lookup(past->states, "scaley")); state_free(dict_lookup(past->states, "cxform.r0")); state_free(dict_lookup(past->states, "cxform.g0")); state_free(dict_lookup(past->states, "cxform.b0")); state_free(dict_lookup(past->states, "cxform.a0")); state_free(dict_lookup(past->states, "cxform.r1")); state_free(dict_lookup(past->states, "cxform.g1")); state_free(dict_lookup(past->states, "cxform.b1")); state_free(dict_lookup(past->states, "cxform.a1")); state_free(dict_lookup(past->states, "rotate")); state_free(dict_lookup(past->states, "shear")); state_free(dict_lookup(past->states, "pivot.x")); state_free(dict_lookup(past->states, "pivot.y")); state_free(dict_lookup(past->states, "pin.x")); state_free(dict_lookup(past->states, "pin.y")); state_free(dict_lookup(past->states, "blendmode")); state_free(dict_lookup(past->states, "flags")); filterState_free(dict_lookup(past->states, "filter")); dict_destroy(past->states); free(past); }
char gfxpoly_check(gfxpoly_t*poly) { dict_t*d = dict_new2(&point_type); int s,t; gfxpolystroke_t*stroke = poly->strokes; for(;stroke;stroke=stroke->next) { for(s=0;s<stroke->num_points;s++) { point_t p = stroke->points[s]; int num = (s>=1 && s<stroke->num_points-1)?2:1; // mid points are two points (start+end) if(!dict_contains(d, &p)) { dict_put(d, &p, (void*)(ptroff_t)num); } else { int count = (ptroff_t)dict_lookup(d, &p); dict_del(d, &p); count+=num; dict_put(d, &p, (void*)(ptroff_t)count); } } } DICT_ITERATE_ITEMS(d, point_t*, p, void*, c) { int count = (ptroff_t)c; if(count&1) { fprintf(stderr, "Point (%f,%f) occurs %d times\n", p->x*poly->gridsize, p->y*poly->gridsize, count); dict_destroy(d); return 0; } }
void mms_cfg_destroy(mCfg *cfg) { List *l; int i, n; gw_assert(cfg); for (i = 0, l = dict_keys(cfg->grps), n = gwlist_len(l); i < n; i++) { Octstr *grpname = gwlist_get(l, i); void *val = dict_get(cfg->grps, grpname); if (is_multigroup(grpname)) { /* item is a list. */ List *gl = val; int j, m = gwlist_len(gl); for (j = 0; j < m; j++) mGrp_destroy(gwlist_get(gl, j)); gwlist_destroy(gl, NULL); } else mGrp_destroy(val); } gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy); dict_destroy(cfg->grps); octstr_destroy(cfg->file); if (cfg->xcfg && cfg->cfg_funcs && cfg->cfg_funcs->destroy) cfg->cfg_funcs->destroy(cfg->xcfg); gw_free(cfg); }
/* release all the resources allocated by server */ void server_destroy() { dict_destroy(key_dict); free(_curr_request); free(_curr_reply); bss_destroy(_time_bss); close(_listening_fd); }
int main(void) { Dict *dict; Octstr *foo, *bar; unsigned long i; gwlib_init(); foo = octstr_imm("foo"); bar = octstr_imm("bar"); debug("",0,"Dict simple test."); dict = dict_create(10, NULL); dict_put(dict, foo, bar); info(0, "foo gives %s", octstr_get_cstr(dict_get(dict, foo))); if (dict_key_count(dict) == 1) info(0, "there is but one foo."); else error(0, "key count is %ld, should be 1.", dict_key_count(dict)); dict_destroy(dict); debug("",0,"Dict extended/huge test."); dict = dict_create(HUGE_SIZE, (void (*)(void *))octstr_destroy); for (i = 1; i <= HUGE_SIZE; i++) { unsigned long val; Octstr *okey, *oval; uuid_t id; char key[UUID_STR_LEN + 1]; uuid_generate(id); uuid_unparse(id, key); val = gw_rand(); okey = octstr_create(key); oval = octstr_format("%ld", val); dict_put(dict, okey, oval); } gwthread_sleep(5); /* give hash table some time */ if (dict_key_count(dict) == HUGE_SIZE) info(0, "ok, got %d entries in the dictionary.", HUGE_SIZE); else error(0, "key count is %ld, should be %d.", dict_key_count(dict), HUGE_SIZE); dict_destroy(dict); gwlib_shutdown(); return 0; }
void methodstate_destroy(methodstate_t*m) { dict_destroy(m->unresolved_variables); m->unresolved_variables = 0; list_free(m->innerfunctions);m->innerfunctions=0; if(m->allvars) { DICT_ITERATE_DATA(m->allvars, void*, data) {free(data);} m->allvars = 0; }
Imp_Dlls::~Imp_Dlls() { if ( m_dict ) { dict_free(m_dict); dict_destroy(m_dict); m_dict = NULL; } }
void state_destroy(state_t*state) { if(state->has_own_imports) { list_free(state->wildcard_imports); dict_destroy(state->imports);state->imports=0; } if(state->imports && (!state->old || state->old->imports!=state->imports)) { dict_destroy(state->imports);state->imports=0; } if(state->vars) { dict_destroy(state->vars);state->vars=0; } list_free(state->active_namespace_urls) state->active_namespace_urls = 0; free(state); }
int main(int argc, char **argv) { int cf_index; Octstr *filename, *version; gwlib_init(); list_dict = dict_create(32, msg_list_destroy_item); cf_index = get_and_set_debugs(argc, argv, check_args); setup_signal_handlers(); if (argv[cf_index] == NULL) filename = octstr_create("httpClient.conf"); else filename = octstr_create(argv[cf_index]); cfg = cfg_create(filename); /* Adding cfg-checks to core */ cfg_add_hooks(smppbox_is_allowed_in_group, smppbox_is_single_group); if (cfg_read(cfg) == -1) panic(0, "Couldn't read configuration from `%s'.", octstr_get_cstr(filename)); octstr_destroy(filename); version = octstr_format("httpClient version %s gwlib", GW_VERSION); report_versions(octstr_get_cstr(version)); octstr_destroy(version); struct server_type *res = NULL; res = sqlbox_init_mysql(cfg); sqlbox_configure_mysql(cfg); init_smpp_server_box(cfg); http_client_box_run(); //gwthread_join_every(sql_to_smpp); //gwthread_join_every(smpp_to_sql); smpp_server_box_shutdown(); dict_destroy(list_dict); list_dict = NULL; cfg_destroy(cfg); if (restart_httpbox) { gwthread_sleep(1.0); } gw_smpp_leave(); gwlib_shutdown(); if (restart_httpbox) execvp(argv[0], argv); return 0; }
END_TEST START_TEST(test_dict_create2) { Dict dict; dict_init(&dict); for (int i = 0; i < 256; i++) ck_assert_int_eq(dict.nodes[i].icount, 0); dict_destroy(&dict); }
RP_mapping::~RP_mapping() { if ( NULL != mapping ) { dict_free(mapping); dict_destroy(mapping); } if ( our_file != NULL ) qfree(our_file); }
static void clipboard_clear_cb (GtkClipboard *clipboard, gpointer data) { dict_destroy (clip_dict); clip_dict = NULL; casereader_destroy (clip_datasheet); clip_datasheet = NULL; }
/************************************************************************* * dict_union: merges contents of 2 dictionaries into * a third * * dict1 - pointer to dictionary 1 * dict2 - pointer to dictionary 2 * * Returns: dictionary pointer * NULL - failed to merge * non-NULL - pointer to new dictionary * * Notes: entries of the same string have their counts * added and their flags ORed together. *************************************************************************/ DICTIONARY *dict_union( const DICTIONARY *dict1 , const DICTIONARY *dict2 ) { DICTIONARY *dict = NULL; STRING_ENTRY *se, *se2; long initial_string_count, initial_hash_chains, max_chain_length; long i, string_index; /*********** ** Initialize the new dictionary. ***********/ if ( dict1==NULL || dict2==NULL ) goto err_exit; if ((dict=(DICTIONARY *)malloc(sizeof(DICTIONARY))) == NULL) goto err_exit; initial_string_count = dict1->string_max; initial_hash_chains = dict1->table_size; max_chain_length = dict1->allowable_chain_length; dict = dict_create( 4, initial_string_count, initial_hash_chains, max_chain_length ); /*********** ** Copy the entries from dict1 into the new dictionary. ***********/ for ( i = 0 ; i < dict1->entry_count ; i++ ) { se = (STRING_ENTRY*)&dict1->string_table[i]; if ( se->count > 0 ) { se2 = dict_insert( dict, dict1->string_array+se->string_offset, se->count, se->flags, NULL, &string_index ); if ( se2 == NULL ) goto err_exit; } /* endif */ } /* endfor */ /* Merge the entries from dict2 into the new dictionary. */ if ( dict_merge(dict,dict2,FALSE) == FALSE ) goto err_exit; /* Success. Return a pointer to the new dictionary. */ return( dict ); /* Failure. Ignominiously erase our tracks and return NULL. */ err_exit: dict_destroy( dict ); return NULL; }
int __stdcall FsFindClose(HANDLE Hdl) { FindStruc *pFind = (FindStruc *)Hdl; if(pFind != NULL) { if(pFind->dict != NULL) { dict_destroy(&pFind->dict); } free(pFind); pFind = NULL; } return 0; }
// add to libft void destroy_array_dict(t_dict **dicts, int dict_len) { int i; i = 0; while (i < dict_len) { dict_destroy(dicts[i]); i++; } }
int cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; int sent = 0; int parse_error = 0; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; if (wordcount != 4) { cli_usage_out (word->pattern); parse_error = 1; goto out; } ret = dict_set_str (dict, "old-volname", (char *)words[2]); if (ret) goto out; ret = dict_set_str (dict, "new-volname", (char *)words[3]); if (ret) goto out; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RENAME_VOLUME]; if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (dict) dict_destroy (dict); if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Volume rename on '%s' failed", (char *)words[2]); } return ret; }
static void destroy_group(void *arg) { CfgGroup *grp; if (arg != NULL) { grp = arg; octstr_destroy(grp->name); octstr_destroy(grp->configfile); dict_destroy(grp->vars); gw_free(grp); } }