# HG changeset patch # User Kenichi Handa # Date 1141441144 0 # Node ID bba59a8cdae0dfa9804d6705ab4f04333718ec91 # Parent 42139b4c2a78a38a2f7ca1dfe4dabb8a50525e65 (encode_coding_ccl): Allocate destination dynamically when necessary. diff -r 42139b4c2a78 -r bba59a8cdae0 src/coding.c --- a/src/coding.c Fri Mar 03 11:47:12 2006 +0000 +++ b/src/coding.c Sat Mar 04 02:59:04 2006 +0000 @@ -4537,7 +4537,6 @@ int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; - unsigned char *adjusted_dst_end = dst_end - 1; int destination_charbuf[1024]; int i, produced_chars = 0; Lisp_Object attrs, charset_list; @@ -4548,24 +4547,27 @@ ccl.last_block = coding->mode & CODING_MODE_LAST_BLOCK; ccl.dst_multibyte = coding->dst_multibyte; - while (charbuf < charbuf_end && dst < adjusted_dst_end) - { - int dst_bytes = dst_end - dst; - if (dst_bytes > 1024) - dst_bytes = 1024; - + while (charbuf < charbuf_end) + { ccl_driver (&ccl, charbuf, destination_charbuf, - charbuf_end - charbuf, dst_bytes, charset_list); - charbuf += ccl.consumed; + charbuf_end - charbuf, 1024, charset_list); if (multibytep) - for (i = 0; i < ccl.produced; i++) - EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); + { + ASSURE_DESTINATION (ccl.produced * 2); + for (i = 0; i < ccl.produced; i++) + EMIT_ONE_BYTE (destination_charbuf[i] & 0xFF); + } else { + ASSURE_DESTINATION (ccl.produced); for (i = 0; i < ccl.produced; i++) *dst++ = destination_charbuf[i] & 0xFF; produced_chars += ccl.produced; } + charbuf += ccl.consumed; + if (ccl.status == CCL_STAT_QUIT + || ccl.status == CCL_STAT_INVALID_CMD) + break; } switch (ccl.status)