========================================================================= * Copy the source state to the destination state. * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */
(dest, source)
| 892 | * doesn't have enough memory anyway to duplicate compression states). |
| 893 | */ |
| 894 | int ZEXPORT deflateCopy (dest, source) |
| 895 | z_streamp dest; |
| 896 | z_streamp source; |
| 897 | { |
| 898 | #ifdef MAXSEG_64K |
| 899 | return Z_STREAM_ERROR; |
| 900 | #else |
| 901 | deflate_state *ds; |
| 902 | deflate_state *ss; |
| 903 | ushf *overlay; |
| 904 | |
| 905 | |
| 906 | if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { |
| 907 | return Z_STREAM_ERROR; |
| 908 | } |
| 909 | |
| 910 | ss = source->state; |
| 911 | |
| 912 | zmemcpy(dest, source, sizeof(z_stream)); |
| 913 | |
| 914 | ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); |
| 915 | if (ds == Z_NULL) return Z_MEM_ERROR; |
| 916 | dest->state = (struct internal_state FAR *) ds; |
| 917 | zmemcpy(ds, ss, sizeof(deflate_state)); |
| 918 | ds->strm = dest; |
| 919 | |
| 920 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); |
| 921 | ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); |
| 922 | ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); |
| 923 | overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); |
| 924 | ds->pending_buf = (uchf *) overlay; |
| 925 | |
| 926 | if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || |
| 927 | ds->pending_buf == Z_NULL) { |
| 928 | deflateEnd (dest); |
| 929 | return Z_MEM_ERROR; |
| 930 | } |
| 931 | /* following zmemcpy do not work for 16-bit MSDOS */ |
| 932 | zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); |
| 933 | zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); |
| 934 | zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); |
| 935 | zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); |
| 936 | |
| 937 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |
| 938 | ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); |
| 939 | ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; |
| 940 | |
| 941 | ds->l_desc.dyn_tree = ds->dyn_ltree; |
| 942 | ds->d_desc.dyn_tree = ds->dyn_dtree; |
| 943 | ds->bl_desc.dyn_tree = ds->bl_tree; |
| 944 | |
| 945 | return Z_OK; |
| 946 | #endif /* MAXSEG_64K */ |
| 947 | } |
| 948 | |
| 949 | /* =========================================================================== |
| 950 | * Read a new buffer from the current input stream, update the adler32 |
nothing calls this directly
no test coverage detected