void list_cursor_destroy(struct list_cursor *cur) { assert(cur); assert(cur->list); list_reset(cur); list_unref(cur->list); free(cur); }
int mb_cu_uinit(void) { mb_hdl_del(g_mb_hdl); list_unref(g_mb_req_list); seq_unref(g_seq); printf("mb uinit.\n"); return 0; }
/* * Encode ["nr", "val"] into a JSON format string in allocated memory. * "options" can be JSON_JS or zero; * Returns NULL when out of memory. */ char_u * json_encode_nr_expr(int nr, typval_T *val, int options) { typval_T listtv; typval_T nrtv; char_u *text; nrtv.v_type = VAR_NUMBER; nrtv.vval.v_number = nr; if (rettv_list_alloc(&listtv) == FAIL) return NULL; if (list_append_tv(listtv.vval.v_list, &nrtv) == FAIL || list_append_tv(listtv.vval.v_list, val) == FAIL) { list_unref(listtv.vval.v_list); return NULL; } text = json_encode(&listtv, options); list_unref(listtv.vval.v_list); return text; }
/* * Encode ["nr", "val"] into a JSON format string in allocated memory. * "options" can contain JSON_JS, JSON_NO_NONE and JSON_NL. * Returns NULL when out of memory. */ char_u * json_encode_nr_expr(int nr, typval_T *val, int options) { typval_T listtv; typval_T nrtv; garray_T ga; nrtv.v_type = VAR_NUMBER; nrtv.vval.v_number = nr; if (rettv_list_alloc(&listtv) == FAIL) return NULL; if (list_append_tv(listtv.vval.v_list, &nrtv) == FAIL || list_append_tv(listtv.vval.v_list, val) == FAIL) { list_unref(listtv.vval.v_list); return NULL; } ga_init2(&ga, 1, 4000); if (json_encode_gap(&ga, &listtv, options) == OK && (options & JSON_NL)) ga_append(&ga, '\n'); list_unref(listtv.vval.v_list); return ga.ga_data; }
/* * Make a copy of list "orig". Shallow if "deep" is FALSE. * The refcount of the new list is set to 1. * See item_copy() for "copyID". * Returns NULL when out of memory. */ list_T * list_copy(list_T *orig, int deep, int copyID) { list_T *copy; listitem_T *item; listitem_T *ni; if (orig == NULL) return NULL; copy = list_alloc(); if (copy != NULL) { if (copyID != 0) { /* Do this before adding the items, because one of the items may * refer back to this list. */ orig->lv_copyID = copyID; orig->lv_copylist = copy; } for (item = orig->lv_first; item != NULL && !got_int; item = item->li_next) { ni = listitem_alloc(); if (ni == NULL) break; if (deep) { if (item_copy(&item->li_tv, &ni->li_tv, deep, copyID) == FAIL) { vim_free(ni); break; } } else copy_tv(&item->li_tv, &ni->li_tv); list_append(copy, ni); } ++copy->lv_refcount; if (item != NULL) { list_unref(copy); copy = NULL; } } return copy; }
value_list_builder::~value_list_builder() { list_unref(head_); }
value_list_impl::~value_list_impl() { list_unref(head_); }
static int luaV_list_gc (lua_State *L) { list_unref(luaV_unbox(L, luaV_List, 1)); return 0; }