if (compl_match_array != NULL)
{
pum_undisplay();
- vim_free(compl_match_array);
- compl_match_array = NULL;
+ vim_clear((void **)&compl_match_array);
}
}
compl_T *match;
int i;
- vim_free(compl_pattern);
- compl_pattern = NULL;
- vim_free(compl_leader);
- compl_leader = NULL;
+ vim_clear((void **)&compl_pattern);
+ vim_clear((void **)&compl_leader);
if (compl_first_match == NULL)
return;
compl_cont_status = 0;
compl_started = FALSE;
compl_matches = 0;
- vim_free(compl_pattern);
- compl_pattern = NULL;
- vim_free(compl_leader);
- compl_leader = NULL;
+ vim_clear((void **)&compl_pattern);
+ vim_clear((void **)&compl_leader);
edit_submode_extra = NULL;
- vim_free(compl_orig_text);
- compl_orig_text = NULL;
+ vim_clear((void **)&compl_orig_text);
compl_enter_selects = FALSE;
/* clear v:completed_item */
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
-1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
{
- vim_free(compl_pattern);
- compl_pattern = NULL;
- vim_free(compl_orig_text);
- compl_orig_text = NULL;
+ vim_clear((void **)&compl_pattern);
+ vim_clear((void **)&compl_orig_text);
return FAIL;
}
void
free_last_insert(void)
{
- vim_free(last_insert);
- last_insert = NULL;
+ vim_clear((void **)&last_insert);
# ifdef FEAT_INS_EXPAND
- vim_free(compl_orig_text);
- compl_orig_text = NULL;
+ vim_clear((void **)&compl_orig_text);
# endif
}
#endif
static void
replace_flush(void)
{
- vim_free(replace_stack);
- replace_stack = NULL;
+ vim_clear((void **)&replace_stack);
replace_stack_len = 0;
replace_stack_nr = 0;
}
}
}
+/*
+ * Like vim_free(), and also set the pointer to NULL.
+ */
+ void
+vim_clear(void **x)
+{
+ if (*x != NULL)
+ {
+ vim_free(*x);
+ *x = NULL;
+ }
+}
+
#ifndef HAVE_MEMSET
void *
vim_memset(void *ptr, int c, size_t size)
prev2 = prev1;
prev1 = c1;
- i += MB_PTR2LEN(s1 + i);
- j += MB_PTR2LEN(s2 + j);
+ i += MB_PTR2LEN(s1 + i);
+ j += MB_PTR2LEN(s2 + j);
}
return s1[i] == s2[j];
}
if (c2 == NUL) /* full match */
return 0;
s = q;
- i = j;
+ i = j;
break;
}
void vim_strcat(char_u *to, char_u *from, size_t tosize);
int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars);
void vim_free(void *x);
+void vim_clear(void **x);
int vim_stricmp(char *s1, char *s2);
int vim_strnicmp(char *s1, char *s2, size_t len);
char_u *vim_strchr(char_u *string, int c);