summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src/x-python.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-06-16 11:17:55 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:10:41 +0200
commit1299e08182b4248f2ef4441e2731946f32c0ba7f (patch)
treef128c04dd99c8d7a1225b6e497845a58befd8bc5 /gettext-tools/src/x-python.c
parent1403a591e49c3d8959c55009bf189412f3bb819d (diff)
downloadexternal_gettext-1299e08182b4248f2ef4441e2731946f32c0ba7f.zip
external_gettext-1299e08182b4248f2ef4441e2731946f32c0ba7f.tar.gz
external_gettext-1299e08182b4248f2ef4441e2731946f32c0ba7f.tar.bz2
Avoid quadratic running time when extracting very long strings or very
long comments.
Diffstat (limited to 'gettext-tools/src/x-python.c')
-rw-r--r--gettext-tools/src/x-python.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c
index d19bb29..dcf0602 100644
--- a/gettext-tools/src/x-python.c
+++ b/gettext-tools/src/x-python.c
@@ -221,7 +221,7 @@ comment_add (int c)
size_t len = ((unsigned char) c < 0x80 ? 1 : 2);
if (buflen + len > bufmax)
{
- bufmax += 100;
+ bufmax = 2 * bufmax + 10;
buffer = xrealloc (buffer, bufmax);
}
if ((unsigned char) c < 0x80)
@@ -241,7 +241,7 @@ comment_line_end ()
--buflen;
if (buflen >= bufmax)
{
- bufmax += 100;
+ bufmax = 2 * bufmax + 10;
buffer = xrealloc (buffer, bufmax);
}
buffer[buflen] = '\0';
@@ -716,7 +716,7 @@ phase5_get (token_ty *tp)
{
if (bufpos >= bufmax)
{
- bufmax += 100;
+ bufmax = 2 * bufmax + 10;
buffer = xrealloc (buffer, bufmax);
}
buffer[bufpos++] = c;
@@ -745,7 +745,7 @@ phase5_get (token_ty *tp)
}
if (bufpos >= bufmax)
{
- bufmax += 100;
+ bufmax = 2 * bufmax + 10;
buffer = xrealloc (buffer, bufmax);
}
buffer[bufpos] = '\0';
@@ -847,7 +847,7 @@ phase5_get (token_ty *tp)
len = (uc < 0x10000 ? 1 : 2);
if (bufpos + len > bufmax)
{
- bufmax += 100;
+ bufmax = 2 * bufmax + 10;
buffer =
xrealloc (buffer, bufmax * sizeof (unsigned short));
}