| 624 | | if( ur_stringSlice( ut, tos, &cpA, &cpB ) && cpA ) |
| 625 | | { |
| 626 | | len = cpB - cpA; |
| 627 | | blen = len + (len / 99) + 600; |
| 628 | | |
| 629 | | binN = ur_makeBinary( blen /*+ 4*/ ); |
| 630 | | bin = ur_binPtr( binN ); |
| 631 | | |
| 632 | | if( len > 0 ) |
| 633 | | { |
| 634 | | ret = BZ2_bzBuffToBuffCompress( bin->ptr.c /*+ 4*/, &blen, |
| 635 | | cpA, len, |
| 636 | | 3, 0, 0 ); |
| 637 | | if( ret == BZ_OUTBUFF_FULL ) |
| 638 | | { |
| 639 | | ur_arrayFree( bin ); |
| 640 | | ur_throwErr( UR_ERR_ACCESS, "compress buffer full" ); |
| 641 | | return; |
| 642 | | } |
| 643 | | bin->used = blen; |
| 644 | | } |
| 645 | | |
| 646 | | ur_initType( tos, UT_BINARY ); |
| 647 | | ur_setSeries( tos, binN, 0 ); |
| | 624 | if( ur_seriesMem( ut, tos, &cpA, &cpB ) ) |
| | 625 | { |
| | 626 | if( cpA ) |
| | 627 | { |
| | 628 | len = cpB - cpA; |
| | 629 | blen = len + (len / 99) + 600; |
| | 630 | |
| | 631 | binN = ur_makeBinary( blen /*+ 4*/ ); |
| | 632 | bin = ur_binPtr( binN ); |
| | 633 | |
| | 634 | if( len > 0 ) |
| | 635 | { |
| | 636 | ret = BZ2_bzBuffToBuffCompress( bin->ptr.c /*+ 4*/, &blen, |
| | 637 | cpA, len, |
| | 638 | 3, 0, 0 ); |
| | 639 | if( ret == BZ_OUTBUFF_FULL ) |
| | 640 | { |
| | 641 | ur_arrayFree( bin ); |
| | 642 | ur_throwErr( UR_ERR_ACCESS, "compress buffer full" ); |
| | 643 | return; |
| | 644 | } |
| | 645 | bin->used = blen; |
| | 646 | } |
| | 647 | |
| | 648 | ur_initType( tos, UT_BINARY ); |
| | 649 | ur_setSeries( tos, binN, 0 ); |
| | 650 | } |
| | 651 | } |
| | 652 | else |
| | 653 | { |
| | 654 | ur_throwErr( UR_ERR_DATATYPE, |
| | 655 | "compress expected string!/binary!/vector!" ); |