100 |
ILAttribute *ILProgramItemRemoveAttribute(ILProgramItem *item, |
ILAttribute *ILProgramItemRemoveAttribute(ILProgramItem *item, |
101 |
ILAttribute *attr) |
ILAttribute *attr) |
102 |
{ |
{ |
|
ILAttribute **start; |
|
103 |
ILAttribute *current; |
ILAttribute *current; |
104 |
|
|
105 |
/* Find the start of the attribute list */ |
/* Find the start of the attribute list */ |
106 |
if(item->linked) |
if(item->linked) |
107 |
{ |
{ |
108 |
start = &(((ILProgramItemLink *)(item->attrsOrLink))->customAttrs); |
/* Check if first attribute is the one we are looking for */ |
109 |
|
if(((ILProgramItemLink *)(item->attrsOrLink))->customAttrs == attr) |
110 |
|
{ |
111 |
|
/* Yes it is. So remove it from the list and return the next one. */ |
112 |
|
((ILProgramItemLink *)(item->attrsOrLink))->customAttrs = attr->next; |
113 |
|
return attr->next; |
114 |
|
} |
115 |
|
/* Set the first attribute as staring point */ |
116 |
|
current = ((ILProgramItemLink *)(item->attrsOrLink))->customAttrs; |
117 |
} |
} |
118 |
else |
else |
119 |
{ |
{ |
120 |
start = (ILAttribute **)(&(item->attrsOrLink)); |
/* Check if first attribute is the one we are looking for */ |
121 |
|
if(((ILAttribute *)(item->attrsOrLink)) == attr) |
122 |
|
{ |
123 |
|
/* Yes it is. So remove it from the list and return the next one. */ |
124 |
|
item->attrsOrLink = ((void *)attr->next); |
125 |
|
return attr->next; |
126 |
|
} |
127 |
|
/* Set the first attribute as staring point */ |
128 |
|
current = (ILAttribute *)(item->attrsOrLink); |
129 |
} |
} |
130 |
|
|
131 |
/* Find the attribute and remove it from the list */ |
/* Find the attribute and remove it from the list */ |
132 |
if(*start == attr) |
if(current != 0) |
|
{ |
|
|
*start = attr->next; |
|
|
} |
|
|
else if(*start != 0) |
|
133 |
{ |
{ |
|
current = *start; |
|
134 |
while(current->next != 0 && current->next != attr) |
while(current->next != 0 && current->next != attr) |
135 |
{ |
{ |
136 |
current = current->next; |
current = current->next; |