aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2014-06-28 22:38:36 +0900
committerKenichi Handa2014-06-28 22:38:36 +0900
commitfda6144e04bb1621a7833e6b9c32701afb1563b6 (patch)
treed3e46a992f30f6eddfdcb7b70ade8d2703b80115 /src/coding.c
parentf036e167feaf875873636972b28a4adc12c32254 (diff)
downloademacs-fda6144e04bb1621a7833e6b9c32701afb1563b6.tar.gz
emacs-fda6144e04bb1621a7833e6b9c32701afb1563b6.zip
* coding.c (MAX_CHARBUF_SIZE): Renamed from CHARBUF_SIZE.
(MIN_CHARBUF_SIZE): New macro. (ALLOC_CONVERSION_WORK_AREA): New arg SIZE. Callers changed.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/coding.c b/src/coding.c
index 79f116fc618..64bad7ccbe8 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -7265,13 +7265,16 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
7265 coding->dst_object); 7265 coding->dst_object);
7266} 7266}
7267 7267
7268#define MAX_CHARBUF_SIZE 0x4000
7269#define MIN_CHARBUF_SIZE 0x10
7268 7270
7269#define CHARBUF_SIZE 0x4000 7271#define ALLOC_CONVERSION_WORK_AREA(coding, size) \
7270 7272 do { \
7271#define ALLOC_CONVERSION_WORK_AREA(coding) \ 7273 int units = ((size) > MAX_CHARBUF_SIZE ? MAX_CHARBUF_SIZE \
7272 do { \ 7274 : (size) < MIN_CHARBUF_SIZE ? MIN_CHARBUF_SIZE \
7273 coding->charbuf = SAFE_ALLOCA (CHARBUF_SIZE * sizeof (int)); \ 7275 : size); \
7274 coding->charbuf_size = CHARBUF_SIZE; \ 7276 coding->charbuf = SAFE_ALLOCA ((units) * sizeof (int)); \
7277 coding->charbuf_size = (units); \
7275 } while (0) 7278 } while (0)
7276 7279
7277 7280
@@ -7373,7 +7376,7 @@ decode_coding (struct coding_system *coding)
7373 record_conversion_result (coding, CODING_RESULT_SUCCESS); 7376 record_conversion_result (coding, CODING_RESULT_SUCCESS);
7374 coding->errors = 0; 7377 coding->errors = 0;
7375 7378
7376 ALLOC_CONVERSION_WORK_AREA (coding); 7379 ALLOC_CONVERSION_WORK_AREA (coding, coding->src_bytes);
7377 7380
7378 attrs = CODING_ID_ATTRS (coding->id); 7381 attrs = CODING_ID_ATTRS (coding->id);
7379 translation_table = get_translation_table (attrs, 0, NULL); 7382 translation_table = get_translation_table (attrs, 0, NULL);
@@ -7769,7 +7772,7 @@ encode_coding (struct coding_system *coding)
7769 record_conversion_result (coding, CODING_RESULT_SUCCESS); 7772 record_conversion_result (coding, CODING_RESULT_SUCCESS);
7770 coding->errors = 0; 7773 coding->errors = 0;
7771 7774
7772 ALLOC_CONVERSION_WORK_AREA (coding); 7775 ALLOC_CONVERSION_WORK_AREA (coding, coding->src_chars);
7773 7776
7774 if (coding->encoder == encode_coding_ccl) 7777 if (coding->encoder == encode_coding_ccl)
7775 { 7778 {