mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 16:21:06 +00:00
Update.
2001-07-23 Ulrich Drepper <drepper@redhat.com> * posix/regex.c: Revamp memory allocation for WCHAR functions to not use too much stack.
This commit is contained in:
parent
bbdf828564
commit
a9d61e2988
@ -1,3 +1,8 @@
|
|||||||
|
2001-07-23 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* posix/regex.c: Revamp memory allocation for WCHAR functions to
|
||||||
|
not use too much stack.
|
||||||
|
|
||||||
2001-07-22 Ulrich Drepper <drepper@redhat.com>
|
2001-07-22 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* iconv/iconvconfig.c (write_output): Update comment explaining
|
* iconv/iconvconfig.c (write_output): Update comment explaining
|
||||||
|
@ -5072,16 +5072,35 @@ weak_alias (__re_search_2, re_search_2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WCHAR
|
#ifdef WCHAR
|
||||||
|
# define MAX_ALLOCA_SIZE 2000
|
||||||
|
|
||||||
# define FREE_WCS_BUFFERS() \
|
# define FREE_WCS_BUFFERS() \
|
||||||
do { \
|
do { \
|
||||||
FREE_VAR (string1); \
|
if (size1 > MAX_ALLOCA_SIZE) \
|
||||||
FREE_VAR (string2); \
|
{ \
|
||||||
|
free (wcs_string1); \
|
||||||
|
free (mbs_offset1); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
FREE_VAR (wcs_string1); \
|
||||||
FREE_VAR (mbs_offset1); \
|
FREE_VAR (mbs_offset1); \
|
||||||
|
} \
|
||||||
|
if (size2 > MAX_ALLOCA_SIZE) \
|
||||||
|
{ \
|
||||||
|
free (wcs_string2); \
|
||||||
|
free (mbs_offset2); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
FREE_VAR (wcs_string2); \
|
||||||
FREE_VAR (mbs_offset2); \
|
FREE_VAR (mbs_offset2); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
|
PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
|
||||||
regs, stop)
|
regs, stop)
|
||||||
@ -5155,36 +5174,72 @@ PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
|
|||||||
/* Allocate wchar_t array for wcs_string1 and wcs_string2 and
|
/* Allocate wchar_t array for wcs_string1 and wcs_string2 and
|
||||||
fill them with converted string. */
|
fill them with converted string. */
|
||||||
if (size1 != 0)
|
if (size1 != 0)
|
||||||
|
{
|
||||||
|
if (size1 > MAX_ALLOCA_SIZE)
|
||||||
|
{
|
||||||
|
wcs_string1 = TALLOC (size1 + 1, CHAR_T);
|
||||||
|
mbs_offset1 = TALLOC (size1 + 1, int);
|
||||||
|
is_binary = TALLOC (size1 + 1, char);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
wcs_string1 = REGEX_TALLOC (size1 + 1, CHAR_T);
|
wcs_string1 = REGEX_TALLOC (size1 + 1, CHAR_T);
|
||||||
mbs_offset1 = REGEX_TALLOC (size1 + 1, int);
|
mbs_offset1 = REGEX_TALLOC (size1 + 1, int);
|
||||||
is_binary = REGEX_TALLOC (size1 + 1, char);
|
is_binary = REGEX_TALLOC (size1 + 1, char);
|
||||||
|
}
|
||||||
if (!wcs_string1 || !mbs_offset1 || !is_binary)
|
if (!wcs_string1 || !mbs_offset1 || !is_binary)
|
||||||
|
{
|
||||||
|
if (size1 > MAX_ALLOCA_SIZE)
|
||||||
|
{
|
||||||
|
free (wcs_string1);
|
||||||
|
free (mbs_offset1);
|
||||||
|
free (is_binary);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
FREE_VAR (wcs_string1);
|
FREE_VAR (wcs_string1);
|
||||||
FREE_VAR (mbs_offset1);
|
FREE_VAR (mbs_offset1);
|
||||||
FREE_VAR (is_binary);
|
FREE_VAR (is_binary);
|
||||||
|
}
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
wcs_size1 = convert_mbs_to_wcs(wcs_string1, string1, size1,
|
wcs_size1 = convert_mbs_to_wcs(wcs_string1, string1, size1,
|
||||||
mbs_offset1, is_binary);
|
mbs_offset1, is_binary);
|
||||||
wcs_string1[wcs_size1] = L'\0'; /* for a sentinel */
|
wcs_string1[wcs_size1] = L'\0'; /* for a sentinel */
|
||||||
|
if (size1 > MAX_ALLOCA_SIZE)
|
||||||
|
free (is_binary);
|
||||||
|
else
|
||||||
FREE_VAR (is_binary);
|
FREE_VAR (is_binary);
|
||||||
}
|
}
|
||||||
if (size2 != 0)
|
if (size2 != 0)
|
||||||
|
{
|
||||||
|
if (size2 > MAX_ALLOCA_SIZE)
|
||||||
|
{
|
||||||
|
wcs_string2 = TALLOC (size2 + 1, CHAR_T);
|
||||||
|
mbs_offset2 = TALLOC (size2 + 1, int);
|
||||||
|
is_binary = TALLOC (size2 + 1, char);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
wcs_string2 = REGEX_TALLOC (size2 + 1, CHAR_T);
|
wcs_string2 = REGEX_TALLOC (size2 + 1, CHAR_T);
|
||||||
mbs_offset2 = REGEX_TALLOC (size2 + 1, int);
|
mbs_offset2 = REGEX_TALLOC (size2 + 1, int);
|
||||||
is_binary = REGEX_TALLOC (size2 + 1, char);
|
is_binary = REGEX_TALLOC (size2 + 1, char);
|
||||||
|
}
|
||||||
if (!wcs_string2 || !mbs_offset2 || !is_binary)
|
if (!wcs_string2 || !mbs_offset2 || !is_binary)
|
||||||
{
|
{
|
||||||
FREE_WCS_BUFFERS ();
|
FREE_WCS_BUFFERS ();
|
||||||
|
if (size2 > MAX_ALLOCA_SIZE)
|
||||||
|
free (is_binary);
|
||||||
|
else
|
||||||
FREE_VAR (is_binary);
|
FREE_VAR (is_binary);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
wcs_size2 = convert_mbs_to_wcs(wcs_string2, string2, size2,
|
wcs_size2 = convert_mbs_to_wcs(wcs_string2, string2, size2,
|
||||||
mbs_offset2, is_binary);
|
mbs_offset2, is_binary);
|
||||||
wcs_string2[wcs_size2] = L'\0'; /* for a sentinel */
|
wcs_string2[wcs_size2] = L'\0'; /* for a sentinel */
|
||||||
|
if (size2 > MAX_ALLOCA_SIZE)
|
||||||
|
free (is_binary);
|
||||||
|
else
|
||||||
FREE_VAR (is_binary);
|
FREE_VAR (is_binary);
|
||||||
}
|
}
|
||||||
#endif /* WCHAR */
|
#endif /* WCHAR */
|
||||||
|
Loading…
Reference in New Issue
Block a user