version 1.1.1.1, 2011/06/08 07:09:12
|
version 1.1.1.2, 2012/02/17 12:50:03
|
Line 126 axlNodeAttr * __axl_node_copy_attr_list (axlNodeAttr *
|
Line 126 axlNodeAttr * __axl_node_copy_attr_list (axlNodeAttr *
|
/* alloc memory to hold attribute name and value, and |
/* alloc memory to hold attribute name and value, and |
* copy it from the list */ |
* copy it from the list */ |
result = axl_new (axlNodeAttr, 1); |
result = axl_new (axlNodeAttr, 1); |
|
/* check allocated result */ |
|
if (result == NULL) |
|
return NULL; |
result->attribute = axl_strdup (list->attribute); |
result->attribute = axl_strdup (list->attribute); |
result->value = axl_strdup (list->value); |
result->value = axl_strdup (list->value); |
|
|
Line 1303 axl_bool axl_node_has_attribute (axlNode
|
Line 1306 axl_bool axl_node_has_attribute (axlNode
|
return axl_hash_exists ((axlHash *) node->attributes, (axlPointer) attribute); |
return axl_hash_exists ((axlHash *) node->attributes, (axlPointer) attribute); |
} |
} |
|
|
|
axl_bool __axl_node_remove_attribute_reinsert (axlPointer key, axlPointer data, axlPointer user_data) |
|
{ |
|
|
|
/* re-add attributes into the node */ |
|
axl_node_set_attribute (user_data, key, data); |
|
|
|
return axl_false; /* do not stop until process all nodes */ |
|
} |
|
|
/** |
/** |
* @brief Allows to remove the provided attribute, from the node |
* @brief Allows to remove the provided attribute, from the node |
* provided. |
* provided. |
Line 1317 void axl_node_remove_attribute (axlNode
|
Line 1329 void axl_node_remove_attribute (axlNode
|
{ |
{ |
axlNodeAttr * attr; |
axlNodeAttr * attr; |
axlNodeAttr * previous; |
axlNodeAttr * previous; |
|
axlHash * temp; |
|
|
axl_return_if_fail (node); |
axl_return_if_fail (node); |
axl_return_if_fail (attribute); |
axl_return_if_fail (attribute); |
Line 1348 void axl_node_remove_attribute (axlNode
|
Line 1361 void axl_node_remove_attribute (axlNode
|
axl_free (attr->value); |
axl_free (attr->value); |
axl_free (attr); |
axl_free (attr); |
} /* end if */ |
} /* end if */ |
|
|
|
/* update attribute count */ |
|
node->attr_num--; |
|
|
return; |
return; |
} |
} |
Line 1364 void axl_node_remove_attribute (axlNode
|
Line 1380 void axl_node_remove_attribute (axlNode
|
/* hashed configuration */ |
/* hashed configuration */ |
axl_hash_remove ((axlHash *) node->attributes, (axlPointer) attribute); |
axl_hash_remove ((axlHash *) node->attributes, (axlPointer) attribute); |
|
|
/* do not decrease attribute number | /* update attributes stored */ |
* since it is used to know the kind | |
* of store used. */ | |
|
|
|
node->attr_num = axl_hash_items ((axlHash *) node->attributes); |
|
|
|
/* if we have fewer than the provided number, rebuild structure */ |
|
if (node->attr_num == 10) { |
|
/* reconvert attribute format */ |
|
temp = (axlHash *) node->attributes; |
|
node->attributes = NULL; |
|
node->attr_num = 0; |
|
|
|
/* reinsert nodes */ |
|
axl_hash_foreach (temp, __axl_node_remove_attribute_reinsert, node); |
|
|
|
/* release hash */ |
|
axl_hash_free (temp); |
|
|
|
printf ("Number of items after reinserting..%d\n", node->attr_num); |
|
} /* end if */ |
|
|
return; |
return; |
} |
} |
|
|
Line 1382 void axl_node_remove_attribute (axlNode
|
Line 1414 void axl_node_remove_attribute (axlNode
|
*/ |
*/ |
int axl_node_num_attributes (axlNode * node) |
int axl_node_num_attributes (axlNode * node) |
{ |
{ |
int result = 0; |
|
axlNodeAttr * attr; |
|
|
|
axl_return_val_if_fail (node, -1); |
axl_return_val_if_fail (node, -1); |
|
|
if (node->attr_num <= 10) { |
if (node->attr_num <= 10) { |
/* linked configuration */ | return node->attr_num; |
attr = (axlNodeAttr *) node->attributes; | |
while (attr != NULL) { | |
/* update sum */ | |
result++; | |
| |
/* get the next attribute */ | |
attr = attr->next; | |
} /* end while */ | |
| |
/* attribute not found */ | |
return result; | |
} /* end if */ |
} /* end if */ |
|
|
/* hashed configuration */ |
/* hashed configuration */ |