mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
Use GA_DEEP_CLEAR where appropriate
This commit is contained in:
@@ -5420,20 +5420,12 @@ static int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int
|
|||||||
{
|
{
|
||||||
garray_T join_ga;
|
garray_T join_ga;
|
||||||
int retval;
|
int retval;
|
||||||
join_T *p;
|
|
||||||
|
|
||||||
ga_init(&join_ga, (int)sizeof(join_T), l->lv_len);
|
ga_init(&join_ga, (int)sizeof(join_T), l->lv_len);
|
||||||
retval = list_join_inner(gap, l, sep, echo_style, copyID, &join_ga);
|
retval = list_join_inner(gap, l, sep, echo_style, copyID, &join_ga);
|
||||||
|
|
||||||
/* Dispose each item in join_ga. */
|
# define FREE_JOIN_TOFREE(join) free((join)->tofree)
|
||||||
if (join_ga.ga_data != NULL) {
|
GA_DEEP_CLEAR(&join_ga, join_T, FREE_JOIN_TOFREE);
|
||||||
p = (join_T *)join_ga.ga_data;
|
|
||||||
for (int i = 0; i < join_ga.ga_len; ++i) {
|
|
||||||
free(p->tofree);
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
ga_clear(&join_ga);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@@ -2580,13 +2580,11 @@ char_u *get_scriptname(scid_T id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if defined(EXITFREE) || defined(PROTO)
|
# if defined(EXITFREE) || defined(PROTO)
|
||||||
void free_scriptnames(void)
|
void free_scriptnames()
|
||||||
{
|
{
|
||||||
for (int i = script_items.ga_len; i > 0; --i)
|
# define FREE_SCRIPTNAME(item) free((item)->sn_name)
|
||||||
free(SCRIPT_ITEM(i).sn_name);
|
GA_DEEP_CLEAR(&script_items, scriptitem_T, FREE_SCRIPTNAME);
|
||||||
ga_clear(&script_items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4535,20 +4535,18 @@ void ex_comclear(exarg_T *eap)
|
|||||||
uc_clear(&curbuf->b_ucmds);
|
uc_clear(&curbuf->b_ucmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_ucmd(ucmd_T* cmd) {
|
||||||
|
free(cmd->uc_name);
|
||||||
|
free(cmd->uc_rep);
|
||||||
|
free(cmd->uc_compl_arg);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear all user commands for "gap".
|
* Clear all user commands for "gap".
|
||||||
*/
|
*/
|
||||||
void uc_clear(garray_T *gap)
|
void uc_clear(garray_T *gap)
|
||||||
{
|
{
|
||||||
ucmd_T *cmd;
|
GA_DEEP_CLEAR(gap, ucmd_T, free_ucmd);
|
||||||
|
|
||||||
for (int i = 0; i < gap->ga_len; ++i) {
|
|
||||||
cmd = USER_CMD_GA(gap, i);
|
|
||||||
free(cmd->uc_name);
|
|
||||||
free(cmd->uc_rep);
|
|
||||||
free(cmd->uc_compl_arg);
|
|
||||||
}
|
|
||||||
ga_clear(gap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ex_delcommand(exarg_T *eap)
|
static void ex_delcommand(exarg_T *eap)
|
||||||
@@ -5477,9 +5475,8 @@ static void ex_goto(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
void alist_clear(alist_T *al)
|
void alist_clear(alist_T *al)
|
||||||
{
|
{
|
||||||
while (--al->al_ga.ga_len >= 0)
|
# define FREE_AENTRY_FNAME(arg) free(arg->ae_fname)
|
||||||
free(AARGLIST(al)[al->al_ga.ga_len].ae_fname);
|
GA_DEEP_CLEAR(&al->al_ga, aentry_T, FREE_AENTRY_FNAME);
|
||||||
ga_clear(&al->al_ga);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1336,9 +1336,8 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
|
|||||||
*/
|
*/
|
||||||
void deleteFoldRecurse(garray_T *gap)
|
void deleteFoldRecurse(garray_T *gap)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gap->ga_len; ++i)
|
# define DELETE_FOLD_NESTED(fd) deleteFoldRecurse(&((fd)->fd_nested))
|
||||||
deleteFoldRecurse(&(((fold_T *)(gap->ga_data))[i].fd_nested));
|
GA_DEEP_CLEAR(gap, fold_T, DELETE_FOLD_NESTED);
|
||||||
ga_clear(gap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* foldMarkAdjust() {{{2 */
|
/* foldMarkAdjust() {{{2 */
|
||||||
|
@@ -1424,6 +1424,12 @@ typedef struct {
|
|||||||
|
|
||||||
static garray_T menutrans_ga = GA_EMPTY_INIT_VALUE;
|
static garray_T menutrans_ga = GA_EMPTY_INIT_VALUE;
|
||||||
|
|
||||||
|
#define FREE_MENUTRANS(mt) \
|
||||||
|
menutrans_T* _mt = (mt); \
|
||||||
|
free(_mt->from); \
|
||||||
|
free(_mt->from_noamp); \
|
||||||
|
free(_mt->to)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":menutrans".
|
* ":menutrans".
|
||||||
* This function is also defined without the +multi_lang feature, in which
|
* This function is also defined without the +multi_lang feature, in which
|
||||||
@@ -1441,13 +1447,8 @@ void ex_menutranslate(exarg_T *eap)
|
|||||||
* ":menutrans clear": clear all translations.
|
* ":menutrans clear": clear all translations.
|
||||||
*/
|
*/
|
||||||
if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5))) {
|
if (STRNCMP(arg, "clear", 5) == 0 && ends_excmd(*skipwhite(arg + 5))) {
|
||||||
menutrans_T *tp = (menutrans_T *)menutrans_ga.ga_data;
|
GA_DEEP_CLEAR(&menutrans_ga, menutrans_T, FREE_MENUTRANS);
|
||||||
for (int i = 0; i < menutrans_ga.ga_len; ++i) {
|
|
||||||
free(tp[i].from);
|
|
||||||
free(tp[i].from_noamp);
|
|
||||||
free(tp[i].to);
|
|
||||||
}
|
|
||||||
ga_clear(&menutrans_ga);
|
|
||||||
/* Delete all "menutrans_" global variables. */
|
/* Delete all "menutrans_" global variables. */
|
||||||
del_menutrans_vars();
|
del_menutrans_vars();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -9200,15 +9200,10 @@ static void tree_count_words(char_u *byts, idx_T *idxs)
|
|||||||
// Free the info put in "*su" by spell_find_suggest().
|
// Free the info put in "*su" by spell_find_suggest().
|
||||||
static void spell_find_cleanup(suginfo_T *su)
|
static void spell_find_cleanup(suginfo_T *su)
|
||||||
{
|
{
|
||||||
|
# define FREE_SUG_WORD(sug) free(sug->st_word)
|
||||||
// Free the suggestions.
|
// Free the suggestions.
|
||||||
for (int i = 0; i < su->su_ga.ga_len; ++i) {
|
GA_DEEP_CLEAR(&su->su_ga, suggest_T, FREE_SUG_WORD);
|
||||||
free(SUG(su->su_ga, i).st_word);
|
GA_DEEP_CLEAR(&su->su_sga, suggest_T, FREE_SUG_WORD);
|
||||||
}
|
|
||||||
ga_clear(&su->su_ga);
|
|
||||||
for (int i = 0; i < su->su_sga.ga_len; ++i) {
|
|
||||||
free(SUG(su->su_sga, i).st_word);
|
|
||||||
}
|
|
||||||
ga_clear(&su->su_sga);
|
|
||||||
|
|
||||||
// Free the banned words.
|
// Free the banned words.
|
||||||
hash_clear_all(&su->su_banned, 0);
|
hash_clear_all(&su->su_banned, 0);
|
||||||
|
@@ -550,14 +550,9 @@ void syntax_start(win_T *wp, linenr_T lnum)
|
|||||||
*/
|
*/
|
||||||
static void clear_syn_state(synstate_T *p)
|
static void clear_syn_state(synstate_T *p)
|
||||||
{
|
{
|
||||||
garray_T *gap;
|
|
||||||
|
|
||||||
if (p->sst_stacksize > SST_FIX_STATES) {
|
if (p->sst_stacksize > SST_FIX_STATES) {
|
||||||
gap = &(p->sst_union.sst_ga);
|
# define UNREF_BUFSTATE_EXTMATCH(bs) unref_extmatch((bs)->bs_extmatch)
|
||||||
for (int i = 0; i < gap->ga_len; i++) {
|
GA_DEEP_CLEAR(&(p->sst_union.sst_ga), bufstate_T, UNREF_BUFSTATE_EXTMATCH);
|
||||||
unref_extmatch(SYN_STATE_P(gap)[i].bs_extmatch);
|
|
||||||
}
|
|
||||||
ga_clear(gap);
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < p->sst_stacksize; i++) {
|
for (int i = 0; i < p->sst_stacksize; i++) {
|
||||||
unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch);
|
unref_extmatch(p->sst_union.sst_stack[i].bs_extmatch);
|
||||||
@@ -570,11 +565,8 @@ static void clear_syn_state(synstate_T *p)
|
|||||||
*/
|
*/
|
||||||
static void clear_current_state(void)
|
static void clear_current_state(void)
|
||||||
{
|
{
|
||||||
stateitem_T *sip = (stateitem_T *)(current_state.ga_data);
|
# define UNREF_STATEITEM_EXTMATCH(si) unref_extmatch((si)->si_extmatch)
|
||||||
for (int i = 0; i < current_state.ga_len; i++) {
|
GA_DEEP_CLEAR(¤t_state, stateitem_T, UNREF_STATEITEM_EXTMATCH);
|
||||||
unref_extmatch(sip[i].si_extmatch);
|
|
||||||
}
|
|
||||||
ga_clear(¤t_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user