memmove(sp->newl, orig->newl, len);
memcpy(sp->newl, orig->newl, len);
screen_init(gp, orig, spp)	GS *gp;	SCR *orig, **spp;{	SCR *sp;	size_t len;	*spp = NULL;	CALLOC_RET(orig, sp, SCR *, 1, sizeof(SCR));	*spp = sp;/* INITIALIZED AT SCREEN CREATE. */	sp->id = ++gp->id;	sp->refcnt = 1;	sp->gp = gp;				/* All ref the GS structure. */	sp->ccnt = 2;				/* Anything > 1 */	/*	 * XXX	 * sp->defscroll is initialized by the opts_init() code because	 * we don't have the option information yet.	 */	CIRCLEQ_INIT(&sp->tiq);/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */	if (orig == NULL) {		sp->searchdir = NOTSET;	} else {		/* Alternate file name. */		if (orig->alt_name != NULL &&		    (sp->alt_name = strdup(orig->alt_name)) == NULL)			goto mem;		/* Last executed at buffer. */		if (F_ISSET(orig, SC_AT_SET)) {			F_SET(sp, SC_AT_SET);			sp->at_lbuf = orig->at_lbuf;		}		/* Retain searching/substitution information. */		sp->searchdir = orig->searchdir == NOTSET ? NOTSET : FORWARD;		if (orig->re != NULL && (sp->re =		    v_strdup(sp, orig->re, orig->re_len)) == NULL)			goto mem;		sp->re_len = orig->re_len;		if (orig->subre != NULL && (sp->subre =		    v_strdup(sp, orig->subre, orig->subre_len)) == NULL)			goto mem;		sp->subre_len = orig->subre_len;		if (orig->repl != NULL && (sp->repl =		    v_strdup(sp, orig->repl, orig->repl_len)) == NULL)			goto mem;		sp->repl_len = orig->repl_len;		if (orig->newl_len) {			len = orig->newl_len * sizeof(size_t);			MALLOC(sp, sp->newl, size_t *, len);			if (sp->newl == NULL) {mem:				msgq(orig, M_SYSERR, NULL);				goto err;			}			sp->newl_len = orig->newl_len;			sp->newl_cnt = orig->newl_cnt;			memmove(sp->newl, orig->newl, len);		}		if (opts_copy(orig, sp))			goto err;		F_SET(sp, F_ISSET(orig, SC_EX | SC_VI));	}	if (ex_screen_copy(orig, sp))		/* Ex. */		goto err;	if (v_screen_copy(orig, sp))		/* Vi. */		goto err;	*spp = sp;	return (0);err:	screen_end(sp);	return (1);}