From: Martin Mares Date: Wed, 26 Mar 2003 20:03:40 +0000 (+0000) Subject: Added functions for moving attributes in the chain. X-Git-Tag: holmes-import~1263 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=47af8a9cb91d8935819285341953802eb8466540;p=libucw.git Added functions for moving attributes in the chain. --- diff --git a/lib/object.c b/lib/object.c index 6f047863..fb957bd7 100644 --- a/lib/object.c +++ b/lib/object.c @@ -244,3 +244,43 @@ obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte * after->same = b; return b; } + +void +obj_move_attr_to_head(struct odes *o, uns x) +{ + struct oattr *a, **z; + + z = &o->attrs; + while (a = *z) + { + if (a->attr == x) + { + *z = a->next; + a->next = o->attrs; + o->attrs = a; + break; + } + z = &a->next; + } +} + +void +obj_move_attr_to_tail(struct odes *o, uns x) +{ + struct oattr *a, **z; + + z = &o->attrs; + while (a = *z) + { + if (a->attr == x) + { + *z = a->next; + while (*z) + z = &(*z)->next; + *z = a; + a->next = NULL; + break; + } + z = &a->next; + } +} diff --git a/lib/object.h b/lib/object.h index c1a91798..34d2e71d 100644 --- a/lib/object.h +++ b/lib/object.h @@ -41,5 +41,7 @@ struct oattr *obj_set_attr_num(struct odes *, uns, uns); struct oattr *obj_add_attr(struct odes *, uns, byte *); struct oattr *obj_prepend_attr(struct odes *, uns, byte *); struct oattr *obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte *v); +void obj_move_attr_to_head(struct odes *o, uns); +void obj_move_attr_to_tail(struct odes *o, uns); #endif