+ if (from->ops->copy) {
+ int freeme;
+ php_http_encoding_stream_t *ns;
+
+ if ((freeme = !to)) {
+ to = pemalloc(sizeof(*to), (from->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT));
+ }
+ memset(to, 0, sizeof(*to));
+
+ to->flags = from->flags;
+ to->ops = from->ops;
+ TSRMLS_SET_CTX(to->ts);
+
+ if ((ns = to->ops->copy(from, to))) {
+ return ns;
+ } else {
+ return to;
+ }
+
+ if (freeme) {
+ pefree(to, (to->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT));
+ }