xp_comm_proj/rd_dicom/Papyrus3/PapyList3.c
/********************************************************************************/
/*										*/
/*	InsertInListAt : Create a new Item after the specified cell in the list	*/
/*	and insert the given Object in it.					*/
/*	return : The created cell if OK, NULL otherwise				*/
/*										*/
/********************************************************************************/
InsertInListAt : Create a new Item after the specified cell in the list
and insert the given Object in it.
return : The created cell if OK, NULL otherwise
InsertInListAt : Create a new Item after the specified cell in the list and insert the given Object in it . return : The created cell if OK NULL otherwise
Papy_List *
InsertInListAt (Papy_List **ioListP, Object *inElemToInsertP, PapyShort inPos)
{
  Papy_List	*theWrkP, *theNewCellP;
  PapyShort	i;
  if ((theNewCellP = (Papy_List *) emalloc3 ((PapyULong) sizeof (Papy_List))) == NULL)
    return NULL;
  theNewCellP->object = inElemToInsertP;
  theNewCellP->next   = NULL;
  if (*ioListP == NULL || inPos == 0)
  {
    theNewCellP->next = NULL;
    *ioListP          = theNewCellP;
  }
  else 
  {
    theWrkP = *ioListP;
    for (i = 1; i < inPos; i++)
    {
      if (theWrkP == NULL) return NULL;
      theWrkP = theWrkP->next;
    } 
    theNewCellP->next = theWrkP->next;
    theWrkP->next     = theNewCellP;
  } 
  return theNewCellP;
}
Papy_List * InsertInListAt ( Papy_List * * ioListP , Object * inElemToInsertP , PapyShort inPos ) { Papy_List * theWrkP , * theNewCellP ; PapyShort i ; if ( ( theNewCellP = ( Papy_List * ) emalloc3 ( ( PapyULong ) sizeof ( Papy_List ) ) ) == NULL ) return NULL ; theNewCellP -> object = inElemToInsertP ; theNewCellP -> next = NULL ; if ( * ioListP == NULL || inPos == 0 ) { theNewCellP -> next = NULL ; * ioListP = theNewCellP ; } else { theWrkP = * ioListP ; for ( i = 1 ; i < inPos ; i ++ ) { if ( theWrkP == NULL ) return NULL ; theWrkP = theWrkP -> next ; } theNewCellP -> next = theWrkP -> next ; theWrkP -> next = theNewCellP ; } return theNewCellP ; }
InsertInListAt : Create a new Item after the specified cell in the list
and insert the given Object in it.
InsertInListAt : Create a new Item after the specified cell in the list and insert the given Object in it .
/* create the new cell and put the Object in */ /* if the ioListP is empty */ /* look for the insertion point */ /* for */ /* insert the new element */ /* else */