commit 8165b20fc1e77bdf7a015b3b360fb14ed54c89b0
parent bacb0f717dbe6f5d2311bda2ed937b910a56ed93
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 20 Nov 2017 19:33:23 +0100
build: fix compilation with --disable-browser --disable-tabcomp
While doing that, move the affected function to the utils.c file
and tweak it a bit.
This fixes https://savannah.gnu.org/bugs/?52468.
Diffstat:
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -2348,19 +2348,6 @@ int diralphasort(const void *va, const void *vb)
* have to use multibyte strcasecmp() instead. */
return mbstrcasecmp(a, b);
}
-
-/* Free the memory allocated for array, which should contain len
- * elements. */
-void free_chararray(char **array, size_t len)
-{
- if (array == NULL)
- return;
-
- for (; len > 0; len--)
- free(array[len - 1]);
-
- free(array);
-}
#endif
#ifdef ENABLE_TABCOMP
diff --git a/src/proto.h b/src/proto.h
@@ -315,7 +315,6 @@ void do_savefile(void);
char *real_dir_from_tilde(const char *buf);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
-void free_chararray(char **array, size_t len);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
@@ -591,6 +590,9 @@ void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
+#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
+void free_chararray(char **array, size_t len);
+#endif
const char *fixbounds(const char *r);
#ifdef ENABLE_SPELLER
bool is_separate_word(size_t position, size_t length, const char *buf);
diff --git a/src/utils.c b/src/utils.c
@@ -193,6 +193,20 @@ void sunder(char *str)
}
}
+#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
+/* Free the memory of the given array, which should contain len elements. */
+void free_chararray(char **array, size_t len)
+{
+ if (array == NULL)
+ return;
+
+ while (len > 0)
+ free(array[--len]);
+
+ free(array);
+}
+#endif
+
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)