static int clnt_setup_long_reply(CONN *conn, struct clist **clpp, uint_t length) { if (length == 0) { *clpp = NULL; return (CLNT_RDMA_SUCCESS); } *clpp = clist_alloc(); (*clpp)->rb_longbuf.len = calc_length(length); (*clpp)->rb_longbuf.type = RDMA_LONG_BUFFER; if (rdma_buf_alloc(conn, &((*clpp)->rb_longbuf))) { clist_free(*clpp); *clpp = NULL; return (CLNT_RDMA_FAIL); } (*clpp)->u.c_daddr3 = (*clpp)->rb_longbuf.addr; (*clpp)->c_len = (*clpp)->rb_longbuf.len; (*clpp)->c_next = NULL; (*clpp)->c_dmemhandle = (*clpp)->rb_longbuf.handle; if (clist_register(conn, *clpp, CLIST_REG_DST)) { DTRACE_PROBE(krpc__e__clntrdma__longrep_regbuf); rdma_buf_free(conn, &((*clpp)->rb_longbuf)); clist_free(*clpp); return (CLNT_RDMA_FAIL); } return (CLNT_RDMA_SUCCESS); }
static int try_build_part(struct mailimap_body * root_part, struct mailimap_body * part, uint32_t count, clist ** result) { int r; clist * imap_id_list; uint32_t * id; r = recursive_build_path(root_part, part, &imap_id_list); if (r != MAILIMAP_NO_ERROR) return r; id = malloc(sizeof(* id)); if (id == NULL) { clist_free(imap_id_list); return MAILIMAP_ERROR_MEMORY; } * id = count; r = clist_prepend(imap_id_list, id); if (r < 0) { free(id); clist_free(imap_id_list); return MAILIMAP_ERROR_MEMORY; } * result = imap_id_list; return MAILIMAP_NO_ERROR; }
/* ARGSUSED */ void xdrrdma_destroy(XDR * xdrs) { xrdma_private_t *xdrp = (xrdma_private_t *)(xdrs->x_private); if (xdrp == NULL) return; if (xdrp->xp_wcl) { if (xdrp->xp_flags & XDR_RDMA_WLIST_REG) { (void) clist_deregister(xdrp->xp_conn, xdrp->xp_wcl); rdma_buf_free(xdrp->xp_conn, &xdrp->xp_wcl->rb_longbuf); } clist_free(xdrp->xp_wcl); } if (xdrp->xp_rcl) { if (xdrp->xp_flags & XDR_RDMA_RLIST_REG) { (void) clist_deregister(xdrp->xp_conn, xdrp->xp_rcl); rdma_buf_free(xdrp->xp_conn, &xdrp->xp_rcl->rb_longbuf); } clist_free(xdrp->xp_rcl); } if (xdrp->xp_rcl_xdr) xdrrdma_free_xdr_chunks(xdrp->xp_conn, xdrp->xp_rcl_xdr); (void) kmem_free(xdrs->x_private, sizeof (xrdma_private_t)); xdrs->x_private = NULL; }
LIBETPAN_EXPORT struct mailimap_set * mailimap_set_new_single_item(struct mailimap_set_item * item) { struct mailimap_set * set; clist * list; int r; list = clist_new(); if (list == NULL) return NULL; r = clist_append(list, item); if (r < 0) { clist_free(list); return NULL; } set = mailimap_set_new(list); if (set == NULL) { clist_free(list); return NULL; } return set; }
void gui::delete_context(gui::context_t *ui) { if (ui) { ui->HotItem = LLGUI_INVALID_ID; ui->ActiveItem = LLGUI_INVALID_ID; clist_free(&ui->Toggles); clist_free(&ui->Buttons); // more clist_free() // ... } }
struct peer_manager *peerman_seed(bool use_dns) { struct peer_manager *peers; peers = peerman_new(); if (!peers) return NULL; /* make DNS query for seed data */ clist *tmp, *seedlist = NULL; if (use_dns) seedlist = bu_dns_seed_addrs(); log_debug("peerman: DNS returned %zu addresses", clist_length(seedlist)); clist_shuffle(seedlist); /* import seed data into peerman */ tmp = seedlist; while (tmp) { struct bp_address *addr = tmp->data; tmp = tmp->next; peerman_add_addr(peers, addr, true); free(addr); } clist_free(seedlist); return peers; }
LIBETPAN_EXPORT void mailimf_keywords_free(struct mailimf_keywords * keywords) { clist_foreach(keywords->kw_list, (clist_func) mailimf_phrase_free, NULL); clist_free(keywords->kw_list); free(keywords); }
LIBETPAN_EXPORT void mailimf_address_list_free(struct mailimf_address_list * addr_list) { clist_foreach(addr_list->ad_list, (clist_func) mailimf_address_free, NULL); clist_free(addr_list->ad_list); free(addr_list); }
LIBETPAN_EXPORT void mailimf_mailbox_list_free(struct mailimf_mailbox_list * mb_list) { clist_foreach(mb_list->mb_list, (clist_func) mailimf_mailbox_free, NULL); clist_free(mb_list->mb_list); free(mb_list); }
static Stree stree_remove(Stree s, Topform c) { if (s == NULL) fatal_error("stree_remove, clause not found"); else if (c->weight == s->weight) { clist_remove(c, s->clauses); if (clist_empty(s->clauses) && s->left == NULL && s->right == NULL) { clist_free(s->clauses); free_stree(s); return NULL; } else if (clist_empty(s->clauses)) s->greatest_id = 0; else s->greatest_id = s->clauses->last->c->id; } else if (c->weight < s->weight) s->left = stree_remove(s->left, c); else s->right = stree_remove(s->right, c); { int a = s->left ? s->left->greatest_id : 0; int b = clist_empty(s->clauses) ? 0 : s->clauses->last->c->id; int c = s->right ? s->right->greatest_id : 0; int d = IMAX(b,c); s->greatest_id = IMAX(a,d); } s->n--; return s; } /* stree_remove */
static void nntpdriver_uninitialize(mailsession * session) { struct nntp_session_state_data * data; data = get_data(session); clist_foreach(data->nntp_subscribed_list, (clist_func) free, NULL); clist_free(data->nntp_subscribed_list); if (data->nntp_group_info != NULL) newsnntp_group_free(data->nntp_group_info); if (data->nntp_group_name != NULL) free(data->nntp_group_name); if (data->nntp_userid != NULL) free(data->nntp_userid); if (data->nntp_password != NULL) free(data->nntp_password); newsnntp_free(data->nntp_session); free(data); session->sess_data = NULL; }
bool_t xdrrdma_free_clist(CONN *conn, struct clist *clp) { rdma_buf_free(conn, &clp->rb_longbuf); clist_free(clp); return (TRUE); }
/* * XDR decode the long reply write chunk. */ bool_t xdr_decode_reply_wchunk(XDR *xdrs, struct clist **clist) { bool_t have_rchunk = FALSE; struct clist *first = NULL, *ncl = NULL; uint32_t num_wclist; uint32_t i; if (!xdr_bool(xdrs, &have_rchunk)) return (FALSE); if (have_rchunk == FALSE) return (TRUE); if (!xdr_uint32(xdrs, &num_wclist)) { DTRACE_PROBE(krpc__e__xdrrdma__replywchunk__listlength); return (FALSE); } if (num_wclist == 0) { return (FALSE); } first = ncl = clist_alloc(); for (i = 0; i < num_wclist; i++) { if (i > 0) { ncl->c_next = clist_alloc(); ncl = ncl->c_next; } if (!xdr_uint32(xdrs, &ncl->c_dmemhandle.mrc_rmr)) goto err_out; if (!xdr_uint32(xdrs, &ncl->c_len)) goto err_out; if (!xdr_uint64(xdrs, &ncl->u.c_daddr)) goto err_out; if (ncl->c_len > MAX_SVC_XFER_SIZE) { DTRACE_PROBE( krpc__e__xdrrdma__replywchunk__chunklist_toobig); ncl->c_len = MAX_SVC_XFER_SIZE; } if (!(ncl->c_dmemhandle.mrc_rmr && (ncl->c_len > 0) && ncl->u.c_daddr)) DTRACE_PROBE( krpc__e__xdrrdma__replywchunk__invalid_segaddr); DTRACE_PROBE1(krpc__i__xdr_decode_reply_wchunk_c_len, uint32_t, ncl->c_len); } *clist = first; return (TRUE); err_out: clist_free(first); return (FALSE); }
static int mhdriver_list_folders(mailsession * session, const char * mb, struct mail_list ** result) { clist * list; int r; struct mailmh * mh; struct mail_list * ml; mh = get_mh_session(session); if (mh == NULL) return MAIL_ERROR_BAD_STATE; list = clist_new(); if (list == NULL) return MAIL_ERROR_MEMORY; r = get_list_folders(mh->mh_main, &list); if (r != MAIL_NO_ERROR) return r; ml = mail_list_new(list); if (ml == NULL) goto free; * result = ml; return MAIL_NO_ERROR; free: clist_foreach(list, (clist_func) free, NULL); clist_free(list); return MAIL_ERROR_MEMORY; }
LIBETPAN_EXPORT void mailimap_extension_unregister_all(void) { clist_free(mailimap_extension_list); mailimap_extension_list = NULL; }
void mailpop3_capa_free(struct mailpop3_capa * capa) { clist_foreach(capa->cap_param, (clist_func) free, NULL); clist_free(capa->cap_param); free(capa->cap_name); free(capa); }
static int get_list_folders(struct mailmh_folder * folder, clist ** result) { unsigned int i; clist * list; char * new_filename; int res; int r; list = * result; new_filename = strdup(folder->fl_filename); if (new_filename == NULL) { res = MAIL_ERROR_MEMORY; goto free; } r = mailmh_folder_update(folder); switch (r) { case MAILMH_NO_ERROR: break; default: res = mhdriver_mh_error_to_mail_error(r); free(new_filename); goto free; } r = clist_append(list, new_filename); if (r < 0) { free(new_filename); res = MAIL_ERROR_MEMORY; goto free; } if (folder->fl_subfolders_tab != NULL) { for(i = 0 ; i < carray_count(folder->fl_subfolders_tab) ; i++) { struct mailmh_folder * subfolder; subfolder = carray_get(folder->fl_subfolders_tab, i); r = get_list_folders(subfolder, &list); if (r != MAIL_NO_ERROR) { free(new_filename); res = MAIL_ERROR_MEMORY; goto free; } } } * result = list; free(new_filename); return MAIL_NO_ERROR; free: clist_foreach(list, (clist_func) free, NULL); clist_free(list); return res; }
int newsnntp_xover_single(newsnntp * f, uint32_t article, struct newsnntp_xover_resp_item ** result) { char command[NNTP_STRING_SIZE]; int r; clist * list; clistiter * cur; struct newsnntp_xover_resp_item * item; snprintf(command, NNTP_STRING_SIZE, "XOVER %i\r\n", article); r = send_command(f, command); if (r == -1) return NEWSNNTP_ERROR_STREAM; r = newsnntp_xover_resp(f, &list); if (r != NEWSNNTP_NO_ERROR) return r; cur = clist_begin(list); item = clist_content(cur); clist_free(list); * result = item; return r; }
LIBETPAN_EXPORT int mailimap_get_section_part_from_body(struct mailimap_body * root_part, struct mailimap_body * part, struct mailimap_section_part ** result) { struct mailimap_section_part * section_part; clist * id_list; int r; int res; r = recursive_build_path(root_part, part, &id_list); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } section_part = mailimap_section_part_new(id_list); if (section_part == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_list; } * result = section_part; return MAILIMAP_NO_ERROR; free_list: clist_foreach(id_list, (clist_func) free, NULL); clist_free(id_list); err: return res; }
void nc_conns_gc(struct net_child_info *nci, bool free_all) { clist *dead = NULL; unsigned int n_gc = 0; /* build list of dead connections */ unsigned int i; for (i = 0; i < nci->conns->len; i++) { struct nc_conn *conn = parr_idx(nci->conns, i); if (free_all || conn->dead) dead = clist_prepend(dead, conn); } /* remove and free dead connections */ clist *tmp = dead; while (tmp) { struct nc_conn *conn = tmp->data; tmp = tmp->next; parr_remove(nci->conns, conn); nc_conn_free(conn); n_gc++; } clist_free(dead); log_debug("net: gc'd %u connections", n_gc); }
void mailprivacy_smime_encryption_id_list_clear(struct mailprivacy * privacy, mailmessage * msg) { clist * encryption_id_list; clistiter * iter; LOCK(); encryption_id_list = get_list(privacy, msg); if (encryption_id_list != NULL) { chashdatum key; for(iter = clist_begin(encryption_id_list) ; iter != NULL ; iter = clist_next(iter)) { char * str; str = clist_content(iter); free(str); } clist_free(encryption_id_list); key.data = &msg; key.len = sizeof(msg); chash_delete(encryption_id_hash, &key, NULL); if (chash_count(encryption_id_hash) == 0) { chash_free(encryption_id_hash); encryption_id_hash = NULL; } } UNLOCK(); }
LIBETPAN_EXPORT void mailimf_in_reply_to_free(struct mailimf_in_reply_to * in_reply_to) { clist_foreach(in_reply_to->mid_list, (clist_func) mailimf_msg_id_free, NULL); clist_free(in_reply_to->mid_list); free(in_reply_to); }
LIBETPAN_EXPORT void mailimf_references_free(struct mailimf_references * references) { clist_foreach(references->mid_list, (clist_func) mailimf_msg_id_free, NULL); clist_free(references->mid_list); free(references); }
LIBETPAN_EXPORT void mailimf_fields_free(struct mailimf_fields * fields) { if (fields->fld_list != NULL) { clist_foreach(fields->fld_list, (clist_func) mailimf_field_free, NULL); clist_free(fields->fld_list); } free(fields); }
LIBETPAN_EXPORT void mailimap_quota_quota_data_free(struct mailimap_quota_quota_data * data) { mailimap_astring_free(data->quotaroot); clist_foreach(data->quota_list, (clist_func) &mailimap_quota_quota_resource_free, NULL); clist_free(data->quota_list); free(data); }
LIBETPAN_EXPORT void mailimap_quota_complete_data_free(struct mailimap_quota_complete_data * data) { mailimap_quota_quotaroot_data_free(data->quotaroot_data); clist_foreach(data->quota_list, (clist_func) &mailimap_quota_quota_data_free, NULL); clist_free(data->quota_list); free(data); }
void sig_free(psig_t * sig) { if (sig->name) { qfree(sig->name); sig->name = NULL; } if (sig->dl.lines != NULL) qfree(sig->dl.lines); if (sig->prefs) frefs_free(sig->prefs); if (sig->srefs) frefs_free(sig->srefs); if (sig->cp) clist_free(sig->cp); if (sig->cs) clist_free(sig->cs); qfree(sig); }
static int mailimap_enable_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_capability_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; int res; struct mailimap_capability_data * capabilities; clist * cap_list; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "ENABLED"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_capability_list_parse(fd, buffer, &cur_token, &cap_list, progr_rate, progr_fun); if (r == MAILIMAP_ERROR_PARSE) { cap_list = clist_new(); if (cap_list == NULL) { res = MAILIMAP_ERROR_MEMORY; goto err; } r = MAILIMAP_NO_ERROR; } if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } capabilities = mailimap_capability_data_new(cap_list); if (capabilities == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_list; } * result = capabilities; * indx = cur_token; return MAILIMAP_NO_ERROR; free_list: if (cap_list) { clist_foreach(cap_list, (clist_func) mailimap_capability_free, NULL); clist_free(cap_list); } err: return res; }
void speech_trimmer_free(SpeechTrimmer *self) { bent_cent_marker_free(self->bcm); segmenter_free(self->seg); int i; for (i=0; i<clist_size(self->queue); ++i) carr_free(clist_get(self->queue, i)); clist_free(self->queue); free(self); }
static int mailprivacy_smime_add_encryption_id(struct mailprivacy * privacy, mailmessage * msg, char * encryption_id) { clist * encryption_id_list; int r; int res; LOCK(); res = -1; encryption_id_list = get_list(privacy, msg); if (encryption_id_list == NULL) { if (encryption_id_hash == NULL) encryption_id_hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY); if (encryption_id_hash != NULL) { encryption_id_list = clist_new(); if (encryption_id_list != NULL) { chashdatum key; chashdatum value; key.data = &msg; key.len = sizeof(msg); value.data = encryption_id_list; value.len = 0; r = chash_set(encryption_id_hash, &key, &value, NULL); if (r < 0) clist_free(encryption_id_list); } } } encryption_id_list = get_list(privacy, msg); if (encryption_id_list != NULL) { char * str; str = strdup(encryption_id); if (str != NULL) { r = clist_append(encryption_id_list, str); if (r < 0) { free(str); } else { res = 0; } } } UNLOCK(); return res; }