diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-01-04 15:46:52 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-10-21 10:30:31 -0300 |
commit | 4e32c8f5682004d0571395fe9fa1bc1b73b40f4c (patch) | |
tree | ae864c72985da7a17440e2bf908ba054b12672c3 /posix/fnmatch.c | |
parent | 8a9a59311551e833ca064de44ac23b193e1b704d (diff) | |
download | glibc-4e32c8f5682004d0571395fe9fa1bc1b73b40f4c.tar.gz glibc-4e32c8f5682004d0571395fe9fa1bc1b73b40f4c.tar.xz glibc-4e32c8f5682004d0571395fe9fa1bc1b73b40f4c.zip |
posix: Remove alloca usage for internal fnmatch implementation
This patch replaces the internal fnmatch pattern list generation to use a dynamic array. Checked on x86_64-linux-gnu.
Diffstat (limited to 'posix/fnmatch.c')
-rw-r--r-- | posix/fnmatch.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c index a66c9196c7..51080ab833 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -31,9 +31,6 @@ #include <ctype.h> #include <string.h> #include <stdlib.h> -#if defined _LIBC || HAVE_ALLOCA -# include <alloca.h> -#endif #include <wchar.h> #include <wctype.h> #include <stddef.h> @@ -87,22 +84,6 @@ typedef ptrdiff_t idx_t; #define NO_LEADING_PERIOD(flags) \ ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD)) -#ifndef _LIBC -# if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. */ -# define __libc_use_alloca(n) ((n) < 4032) -# else -/* Just use malloc. */ -# define __libc_use_alloca(n) false -# undef alloca -# define alloca(n) malloc (n) -# endif -# define alloca_account(size, avar) ((avar) += (size), alloca (size)) -#endif - /* Provide support for user-defined character classes, based on the functions from ISO C 90 amendment 1. */ #ifdef CHARCLASS_NAME_MAX @@ -289,8 +270,7 @@ fnmatch (const char *pattern, const char *string, int flags) if (r == 0) r = internal_fnwmatch (wpattern.data, wstring.data, (wchar_t *) wstring.data + n, - flags & FNM_PERIOD, flags, NULL, - false); + flags & FNM_PERIOD, flags, NULL); } scratch_buffer_free (&wstring); @@ -301,7 +281,7 @@ fnmatch (const char *pattern, const char *string, int flags) } return internal_fnmatch (pattern, string, string + strlen (string), - flags & FNM_PERIOD, flags, NULL, 0); + flags & FNM_PERIOD, flags, NULL); } #undef fnmatch |