
/* ###--------------------------------------------------------------### */
/* 									*/
/* file		: syf_beh_crtberin.c					*/
/* date		: Aug 24 1992						*/
/* version	: v102							*/
/* authors	: Pirouz BAZARGAN SABET					*/
/* content	: contains a specific function used to create a		*/
/*		  behaviour data structure				*/
/*									*/
/* ###--------------------------------------------------------------### */

#include MUT_H 
#include LOG_H 
#include BEH_H 

/* ###--------------------------------------------------------------### */
/* function	: syf_beh_crtberin						*/
/* description	: create an array of BETYPs from a list of BETYPs	*/
/* called func.	: namealloc, mbkalloc					*/
/* ###--------------------------------------------------------------### */

struct syf_berin *syf_beh_crtberin (listberin)

struct syf_berin *listberin;	/* pointer on the list of berins	*/

  {
  struct syf_berin *lclberin = listberin;
  struct syf_berin *ptberin  = NULL;
  int           size     = 0;

  while (lclberin != NULL)
    {
    lclberin = lclberin->NEXT;
    size++;
    }

  if (size != 0)
    {
    ptberin  = (struct syf_berin *) mbkalloc (size * sizeof(struct syf_berin));
    lclberin = ptberin;

    while (listberin != NULL)
      {
      lclberin->NAME   = listberin->NAME;
      lclberin->NEXT   = lclberin + 1;

      listberin        = listberin->NEXT;
      lclberin++;
      }

    (lclberin - 1)->NEXT = NULL;
    }

  return (ptberin);
  }
