src/gedlib/replace.c
/*==================================================================
 * replace_fam -- Replace a family in database with modified version
 *  fam1 = current record (copy from database, may or may not be in cache)
 *  fam2 = new data
 *  replaces all children nodes of fam1 with children nodes of fam2
 *  consumes fam2 (calls free_node on it)
 *================================================================*/
- Replace a family in database with modified version
fam1 = current record (copy from database, may or may not be in cache)
fam2 = new data
replaces all children nodes of fam1 with children nodes of fam2
consumes fam2 (calls free_node on it)
- Replace a family in database with modified version fam1 = current record ( copy from database may or may not be in cache ) fam2 = new data replaces all children nodes of fam1 with children nodes of fam2 consumes fam2 ( calls free_node on it )
void
replace_fam (NODE fam1, NODE fam2)
{
	NODE refn1, refn2, husb, wife, chil, body;
	NODE refnn, refn1n, node, fam0;
	STRING key;
	split_fam(fam1, &refn1, &husb, &wife, &chil, &body);
	fam0 = copy_node(fam1);
	join_fam(fam0, NULL, husb, wife, chil, body);
	free_nodes(fam0);
	split_fam(fam2, &refn2, &husb, &wife, &chil, &body);
	refnn = copy_nodes(refn2, TRUE, TRUE);
	join_fam(fam1, refn2, husb, wife, chil, body);
	free_node(fam2);
	fam_to_dbase(fam1);
	key = rmvat(nxref(fam1));
	classify_nodes(&refn1, &refnn, &refn1n);
	for (node = refn1; node; node = nsibling(node))
		if (nval(node)) remove_refn(nval(node), key);
	for (node = refnn; node; node = nsibling(node))
		if (nval(node)) add_refn(nval(node), key);
	free_nodes(refn1);
	free_nodes(refnn);
	free_nodes(refn1n);
}
void replace_fam ( NODE fam1 , NODE fam2 ) { NODE refn1 , refn2 , husb , wife , chil , body ; NODE refnn , refn1n , node , fam0 ; STRING key ; split_fam ( fam1 , & refn1 , & husb , & wife , & chil , & body ) ; fam0 = copy_node ( fam1 ) ; join_fam ( fam0 , NULL , husb , wife , chil , body ) ; free_nodes ( fam0 ) ; split_fam ( fam2 , & refn2 , & husb , & wife , & chil , & body ) ; refnn = copy_nodes ( refn2 , TRUE , TRUE ) ; join_fam ( fam1 , refn2 , husb , wife , chil , body ) ; free_node ( fam2 ) ; fam_to_dbase ( fam1 ) ; key = rmvat ( nxref ( fam1 ) ) ; classify_nodes ( & refn1 , & refnn , & refn1n ) ; for ( node = refn1 ; node ; node = nsibling ( node ) ) if ( nval ( node ) ) remove_refn ( nval ( node ) , key ) ; for ( node = refnn ; node ; node = nsibling ( node ) ) if ( nval ( node ) ) add_refn ( nval ( node ) , key ) ; free_nodes ( refn1 ) ; free_nodes ( refnn ) ; free_nodes ( refn1n ) ; }
replace_fam -- Replace a family in database with modified version
  fam1 = current record (copy from database, may or may not be in cache)
  fam2 = new data
  replaces all children nodes of fam1 with children nodes of fam2
  consumes fam2 (calls free_node on it)
replace_fam -- Replace a family in database with modified version fam1 = current record ( copy from database may or may not be in cache ) fam2 = new data replaces all children nodes of fam1 with children nodes of fam2 consumes fam2 ( calls free_node on it )
/* Move fam1 data into fam0 & delete it (saving refns) */ /* Move fam2 data into fam1, also copy out list of refns */ /* Write data to database */ /* remove deleted refns & add new ones */