emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enlarge MAX_ALLOCA?


From: K. Handa
Subject: Re: Enlarge MAX_ALLOCA?
Date: Sat, 28 Jun 2014 23:15:58 +0900

In article <address@hidden>, address@hidden (K. Handa) writes:

> > Does the patch below look OK to you?  I tried it, but it seems to
> > cause trouble when byte-compiling: Emacs enters some kind of infloop.
> > Perhaps I misunderstood what you meant?

> I have not yet tested your patch,

I tested your patch, and confirmed the stuck.

> but I think it is better
> to limit the maximum allocation size to the current
> CHARBUF_SIZE, and also limit the mininum allocation size to
> 16 units or so.  The latter is because some of
> encode_coding_XXXX need at least a few more slots left in
> coding->charbuf.

So, along the above line, I intalled the attached patch
with which Emacs didn't stuck,

---
Kenichi Handa
address@hidden

=== modified file 'src/coding.c'
--- src/coding.c        2014-06-25 12:11:08 +0000
+++ src/coding.c        2014-06-28 02:10:20 +0000
@@ -7265,13 +7265,16 @@
                      coding->dst_object);
 }
 
+#define MAX_CHARBUF_SIZE 0x4000
+#define MIN_CHARBUF_SIZE 0x10
 
-#define CHARBUF_SIZE 0x4000
-
-#define ALLOC_CONVERSION_WORK_AREA(coding)                             \
-  do {                                                                 \
-    coding->charbuf = SAFE_ALLOCA (CHARBUF_SIZE * sizeof (int));       \
-    coding->charbuf_size = CHARBUF_SIZE;                               \
+#define ALLOC_CONVERSION_WORK_AREA(coding, size)               \
+  do {                                                         \
+    int units = ((size) > MAX_CHARBUF_SIZE ? MAX_CHARBUF_SIZE  \
+                : (size) < MIN_CHARBUF_SIZE ? MIN_CHARBUF_SIZE \
+                : size);                                       \
+    coding->charbuf = SAFE_ALLOCA ((units) * sizeof (int));    \
+    coding->charbuf_size = (units);                            \
   } while (0)
 
 
@@ -7373,7 +7376,7 @@
   record_conversion_result (coding, CODING_RESULT_SUCCESS);
   coding->errors = 0;
 
-  ALLOC_CONVERSION_WORK_AREA (coding);
+  ALLOC_CONVERSION_WORK_AREA (coding, coding->src_bytes);
 
   attrs = CODING_ID_ATTRS (coding->id);
   translation_table = get_translation_table (attrs, 0, NULL);
@@ -7769,7 +7772,7 @@
   record_conversion_result (coding, CODING_RESULT_SUCCESS);
   coding->errors = 0;
 
-  ALLOC_CONVERSION_WORK_AREA (coding);
+  ALLOC_CONVERSION_WORK_AREA (coding, coding->src_chars);
 
   if (coding->encoder == encode_coding_ccl)
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]