diff --git a/src/files.c b/src/files.c index 588f7d88aab0548f668fe5d4621140cbf28a733c..4387e8fffeeaa42c11272b1ba75885719b50e429 100644 --- a/src/files.c +++ b/src/files.c @@ -2713,8 +2713,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, char *mzero, *glued; const char *lastslash = revstrstr(buf, "/", buf + *place); size_t lastslash_len = (lastslash == NULL) ? 0 : lastslash - buf + 1; - char *match1 = charalloc(mb_cur_max()); - char *match2 = charalloc(mb_cur_max()); + char match1[mb_cur_max()], match2[mb_cur_max()]; int match1_len, match2_len; /* Get the number of characters that all matches have in common. */ @@ -2735,9 +2734,6 @@ char *input_tab(char *buf, bool allow_files, size_t *place, common_len += match1_len; } - free(match1); - free(match2); - mzero = charalloc(lastslash_len + common_len + 1); strncpy(mzero, buf, lastslash_len); diff --git a/src/utils.c b/src/utils.c index ea3306fc76f1f491e19ea59aeeecbff78a7ef104..83ae7fa7b604cf910450d865562c4a9e84a6e276 100644 --- a/src/utils.c +++ b/src/utils.c @@ -303,9 +303,8 @@ const char *fixbounds(const char *r) * a separate word? That is: is it not part of a longer word?*/ bool is_separate_word(size_t position, size_t length, const char *buf) { - char *before = charalloc(mb_cur_max()), *after = charalloc(mb_cur_max()); + char before[mb_cur_max()], after[mb_cur_max()]; size_t word_end = position + length; - bool retval; /* Get the characters before and after the word, if any. */ parse_mbchar(buf + move_mbleft(buf, position), before, NULL); @@ -314,13 +313,8 @@ bool is_separate_word(size_t position, size_t length, const char *buf) /* If the word starts at the beginning of the line OR the character before * the word isn't a letter, and if the word ends at the end of the line OR * the character after the word isn't a letter, we have a whole word. */ - retval = (position == 0 || !is_alpha_mbchar(before)) && - (word_end == strlen(buf) || !is_alpha_mbchar(after)); - - free(before); - free(after); - - return retval; + return ((position == 0 || !is_alpha_mbchar(before)) && + (buf[word_end] == '\0' || !is_alpha_mbchar(after))); } #endif /* !DISABLE_SPELLER */