/*****************************************************************************/ /* */ /* UNIT: NTL1_Copy_Label (Level 1 library routine) */ /* */ /* Author: Nikola Stojanovic */ /* */ /* Revision: 19 JUL 94 Version 1.0 */ /* */ /* Function: */ /* */ /* Procedure copies the received link list of label cells into a newly */ /* allocated list; returns the pointer to the head of the copied list */ /* */ /*****************************************************************************/ #include #include #include "ntl1.h" /*****************************************************************************/ label_ptr NTL1_Copy_Label (label_ptr original) { label_ptr new_head, current, scan; if (original == NULL) return NULL; /* Nothing to be copied */ else { /* Handle the first label fraction record separately, to ease the addition */ /* of other fractions to the end of the copied list */ new_head = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); /* Proceed to adjust the contents of all "attached" lists of the copy */ if (original -> text != NULL) new_head -> text = NTL0_strsave (original -> text); else new_head -> text = NULL; if (original -> font_name != NULL) new_head -> font_name = NTL0_strsave (original -> font_name); else new_head -> font_name = NULL; new_head -> font_size = original -> font_size; new_head -> next = original -> next; current = new_head; /* Initialize to new head - guaranteed previous record */ /* Hand all other label fractions in the list, in their original order */ for (scan = original -> next; scan != NULL; scan = scan -> next) { current -> next = (label_ptr) NTL0_ckalloc (sizeof (Label_Struct)); /* Proceed to adjust the contents of all "attached" lists of the copy */ if (scan -> text != NULL) (current -> next) -> text = NTL0_strsave (scan -> text); else (current -> next) -> text = NULL; if (scan -> font_name != NULL) (current -> next) -> font_name = NTL0_strsave (scan -> font_name); else (current -> next) -> font_name = NULL; (current -> next) -> font_size = scan -> font_size; (current -> next) -> next = scan -> next; current = current -> next; } return new_head; /* Pointer to the head of the copied list */ } }