 /* File copintal_prot.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif


  ALIGNMENT_INT_PROT *copy_int_al_prot(ALIGNMENT_INT_PROT *p2, ALIGNMENT_INT_PROT *p1)
 /*****************************************/
 /*   Copies *p1 into *p2, both of which  */
 /* are assumed to already exist.         */
 /* Returns *p2.                          */
 /*****************************************/
 {
/* local data: */
  char *proc = " copy_int_al_prot";
  int i;
  PROTECTED_INT_STR **new_auxtab; /* dynamically allocated */
/* code: */
 db_enter_msg(proc,3); /* debug only */
  p2->aligned = p1->aligned;
  p2->d = p1->d;
  p2->nsa = nstrcpy_prot_p(p2->nsa,p1->nsa);
  p2->nsb = nstrcpy_prot_p(p2->nsb,p1->nsb);
  p2->pcset = p1->pcset;
  p2->ia = p1->ia;
  p2->jb = p2->jb;
  if (p1->naux > p2->max_aux)
    {/* expand p2 auxtab area to fit p1 auxtab */
     p2->max_aux = p1->max_aux;
     new_auxtab = (PROTECTED_INT_STR**)calloc_safe(p2->max_aux+1,sizeof(PROTECTED_INT_STR*),proc);
if (db_level > 3) printf("%s allocated new_auxtab at %x\n",pdb,(int)new_auxtab);
     for (i=0; i <= p2->max_aux; i++)
       {if (i <= p2->naux-1) new_auxtab[i] = p2->auxtab[i];
        else                 new_auxtab[i] = NULL;
       }
if (db_level > 3) printf("%s freeing %s->auxtab at %x\n",pdb,p2->id->str,(int)p2->auxtab);
     free((char*)p2->auxtab);
if (db_level > 3) printf("%s setting %s->auxtab to new_auxtab (%x)\n",pdb,p2->id->str,(int)new_auxtab);
     p2->auxtab = new_auxtab;
    }
  p2->naux = p1->naux;
  for (i=1; i <= p1->naux; i++)
    {if (p2->auxtab[i] == NULL) p2->auxtab[i] = create_prot_int_str(4);
     nstrcpy_prot_p(p2->auxtab[i],p1->auxtab[i]);
    }
 db_leave_msg(proc,3); /* debug only */
  return p2;
  } /* end of function "copy_int_al_prot" */
 /* end file copintal_prot.c */
