diff options
author | Kenichi Handa <handa@gnu.org> | 2014-06-28 22:38:36 +0900 |
---|---|---|
committer | Kenichi Handa <handa@gnu.org> | 2014-06-28 22:38:36 +0900 |
commit | fda6144e04bb1621a7833e6b9c32701afb1563b6 (patch) | |
tree | d3e46a992f30f6eddfdcb7b70ade8d2703b80115 /src/coding.c | |
parent | f036e167feaf875873636972b28a4adc12c32254 (diff) | |
download | emacs-fda6144e04bb1621a7833e6b9c32701afb1563b6.tar.gz |
* 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.c | 19 |
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) 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 @@ decode_coding (struct coding_system *coding) 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 @@ encode_coding (struct coding_system *coding) 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) { |