Index: trunk/src/attrib.c =================================================================== --- trunk/src/attrib.c (revision 5191) +++ trunk/src/attrib.c (revision 5192) @@ -70,17 +70,24 @@ return 0; } +int pcb_attribute_remove_idx(pcb_attribute_list_t * list, int idx) +{ + int j; + free(list->List[idx].name); + free(list->List[idx].value); + for (j = idx; j < list->Number-1; j++) + list->List[j] = list->List[j + 1]; + list->Number--; + return 0; +} + int pcb_attribute_remove(pcb_attribute_list_t * list, const char *name) { - int i, j, found = 0; + int i, found = 0; for (i = 0; i < list->Number; i++) if (strcmp(name, list->List[i].name) == 0) { - free(list->List[i].name); - free(list->List[i].value); found++; - for (j = i; j < list->Number - i; j++) - list->List[j] = list->List[j + 1]; - list->Number--; + pcb_attribute_remove_idx(list, i); } return found; } Index: trunk/src/attrib.h =================================================================== --- trunk/src/attrib.h (revision 5191) +++ trunk/src/attrib.h (revision 5192) @@ -57,6 +57,9 @@ /* Simplistic version of Remove. */ #define pcb_attrib_remove(OBJ, name) pcb_attribute_remove(&(OBJ->Attributes), name) +/* remove item by index - WARNING: no checks are made, idx has to be valid! */ +int pcb_attribute_remove_idx(pcb_attribute_list_t * list, int idx); + /* Frees memory used by an attribute list */ void pcb_attribute_free(pcb_attribute_list_t *list);