========================================================================= * 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). */
| 1013 | * doesn't have enough memory anyway to duplicate compression states). |
| 1014 | */ |
| 1015 | int ZEXPORT deflateCopy (z_streamp dest, z_streamp source) |
| 1016 | { |
| 1017 | #ifdef MAXSEG_64K |
| 1018 | return Z_STREAM_ERROR; |
| 1019 | #else |
| 1020 | deflate_state *ds; |
| 1021 | deflate_state *ss; |
| 1022 | |
| 1023 | |
| 1024 | if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { |
| 1025 | return Z_STREAM_ERROR; |
| 1026 | } |
| 1027 | |
| 1028 | ss = source->state; |
| 1029 | |
| 1030 | zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); |
| 1031 | |
| 1032 | ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); |
| 1033 | if (ds == Z_NULL) return Z_MEM_ERROR; |
| 1034 | dest->state = (struct internal_state FAR *) ds; |
| 1035 | zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); |
| 1036 | ds->strm = dest; |
| 1037 | |
| 1038 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); |
| 1039 | ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); |
| 1040 | ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); |
| 1041 | ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); |
| 1042 | |
| 1043 | if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || |
| 1044 | ds->pending_buf == Z_NULL) { |
| 1045 | deflateEnd (dest); |
| 1046 | return Z_MEM_ERROR; |
| 1047 | } |
| 1048 | /* following zmemcpy do not work for 16-bit MSDOS */ |
| 1049 | zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); |
| 1050 | zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); |
| 1051 | zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); |
| 1052 | zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); |
| 1053 | |
| 1054 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |
| 1055 | ds->sym_buf = ds->pending_buf + ds->lit_bufsize; |
| 1056 | |
| 1057 | ds->l_desc.dyn_tree = ds->dyn_ltree; |
| 1058 | ds->d_desc.dyn_tree = ds->dyn_dtree; |
| 1059 | ds->bl_desc.dyn_tree = ds->bl_tree; |
| 1060 | |
| 1061 | return Z_OK; |
| 1062 | #endif /* MAXSEG_64K */ |
| 1063 | } |
| 1064 | |
| 1065 | /* =========================================================================== |
| 1066 | * Read a new buffer from the current input stream, update the adler32 |
nothing calls this directly
no test coverage detected