kernels/linux-2.4.0/arch/ia64/sn/io/labelcl.c
/*
 * labelcl_info_add_LBL - Adds a new label entry in the labelcl info 
 *	structure.
 *
 *	Error is returned if we find another label with the same name.
 */
Adds a new label entry in the labelcl info
structure.

Error is returned if we find another label with the same name.
Adds a new label entry in the labelcl info structure . Error is returned if we find another label with the same name .
int
labelcl_info_add_LBL(devfs_handle_t de,
			char *info_name,
			arb_info_desc_t info_desc,
			arbitrary_info_t info)
{
	labelcl_info_t	*labelcl_info = NULL;
	int num_labels;
	int new_label_list_size;
	label_info_t *old_label_list, *new_label_list = NULL;
	char *name;
	int i;
	if (de == NULL)
		return(-1);
        labelcl_info = devfs_get_info(de);
	if (labelcl_info == NULL)
		return(-1);
	if (labelcl_info->hwcl_magic != LABELCL_MAGIC)
		return(-1);
	if (info_name == NULL)
		return(-1);
	if (strlen(info_name) >= LABEL_LENGTH_MAX)
		return(-1);
	name = string_table_insert(&label_string_table, info_name);
	num_labels = labelcl_info->num_labels;
	new_label_list_size = sizeof(label_info_t) * (num_labels+1);
	if (new_label_list_size != 0) {
		new_label_list = (label_info_t *) kmalloc(new_label_list_size, GFP_KERNEL);
		if (new_label_list == NULL)
			return(-1);
	}
	old_label_list = labelcl_info->label_list;
	for (i=0; i<num_labels; i++) {
		if (!strcmp(info_name, old_label_list[i].name)) {
			kfree(new_label_list);
			printk("labelcl_info_add_LBL: Duplicate label name %s for vertex 0x%p\n", info_name, de);
			return(-1);
		}
		new_label_list[i] = old_label_list[i]; 
	}
	new_label_list[num_labels].name = name;
	new_label_list[num_labels].desc = info_desc;
	new_label_list[num_labels].info = info;
	labelcl_info->num_labels = num_labels+1;
	labelcl_info->label_list = new_label_list;
	if (old_label_list != NULL)
		kfree(old_label_list);
	return(0);
}
int labelcl_info_add_LBL ( devfs_handle_t de , char * info_name , arb_info_desc_t info_desc , arbitrary_info_t info ) { labelcl_info_t * labelcl_info = NULL ; int num_labels ; int new_label_list_size ; label_info_t * old_label_list , * new_label_list = NULL ; char * name ; int i ; if ( de == NULL ) return ( -1 ) ; labelcl_info = devfs_get_info ( de ) ; if ( labelcl_info == NULL ) return ( -1 ) ; if ( labelcl_info -> hwcl_magic != LABELCL_MAGIC ) return ( -1 ) ; if ( info_name == NULL ) return ( -1 ) ; if ( strlen ( info_name ) >= LABEL_LENGTH_MAX ) return ( -1 ) ; name = string_table_insert ( & label_string_table , info_name ) ; num_labels = labelcl_info -> num_labels ; new_label_list_size = sizeof ( label_info_t ) * ( num_labels + 1 ) ; if ( new_label_list_size != 0 ) { new_label_list = ( label_info_t * ) kmalloc ( new_label_list_size , GFP_KERNEL ) ; if ( new_label_list == NULL ) return ( -1 ) ; } old_label_list = labelcl_info -> label_list ; for ( i = 0 ; i < num_labels ; i ++ ) { if ( ! strcmp ( info_name , old_label_list [ i ] . name ) ) { kfree ( new_label_list ) ; printk ( " \n " , info_name , de ) ; return ( -1 ) ; } new_label_list [ i ] = old_label_list [ i ] ; } new_label_list [ num_labels ] . name = name ; new_label_list [ num_labels ] . desc = info_desc ; new_label_list [ num_labels ] . info = info ; labelcl_info -> num_labels = num_labels + 1 ; labelcl_info -> label_list = new_label_list ; if ( old_label_list != NULL ) kfree ( old_label_list ) ; return ( 0 ) ; }
labelcl_info_add_LBL - Adds a new label entry in the labelcl info
      structure.
labelcl_info_add_LBL - Adds a new label entry in the labelcl info structure .
/*
	 * Create a new label info area.
	 */ /*
	 * At this point, we are committed to adding the labelled info, 
	 * if there isn't already information there with the same name.
	 */ /* 
	 * Look for matching info name.
	 */ /* Not allowed to add duplicate labelled info names. */ /* structure copy */