rcsnum_free(crev); }
rcsnum_free(crev);
rcs_getrev(RCSFILE *rfp, RCSNUM *rev){	int res;	size_t len;	void *bp;	RCSNUM *crev;	BUF *rbuf;	struct rcs_delta *rdp = NULL;	res = rcsnum_cmp(rfp->rf_head, rev, 0);	if (res == 1) {		cvs_log(LP_ERR, "sorry, can't travel in the future yet");		return (NULL);	} else {		rdp = rcs_findrev(rfp, rfp->rf_head);		if (rdp == NULL) {			cvs_log(LP_ERR, "failed to get RCS HEAD revision");			return (NULL);		}		len = strlen(rdp->rd_text);		rbuf = cvs_buf_alloc(len, BUF_AUTOEXT);		if (rbuf == NULL)			return (NULL);		cvs_buf_append(rbuf, rdp->rd_text, len);		if (res != 0) {			/* Apply patches backwards to get the right version.			 * This will need some rework to support sub branches.			 */			if ((crev = rcsnum_alloc()) == NULL) {				cvs_buf_free(rbuf);				return (NULL);			}			rcsnum_cpy(rfp->rf_head, crev, 0);			do {				crev->rn_id[crev->rn_len - 1]--;				rdp = rcs_findrev(rfp, crev);				if (rdp == NULL) {					rcsnum_free(crev);					cvs_buf_free(rbuf);					return (NULL);				}				if (cvs_buf_putc(rbuf, '\0') < 0) {					rcsnum_free(crev);					cvs_buf_free(rbuf);					return (NULL);				}				bp = cvs_buf_release(rbuf);				rbuf = rcs_patch((char *)bp, rdp->rd_text);				if (rbuf == NULL)					break;			} while (rcsnum_cmp(crev, rev, 0) != 0);			rcsnum_free(crev);		}	}	return (rbuf);}