2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
10 /*****************************************************************************
13 #include <utility/tagitem.h>
14 #include <proto/utility.h>
16 AROS_LH1(struct TagItem
*, CloneTagItems
,
19 AROS_LHA(struct TagItem
*, tagList
, A0
),
22 struct UtilityBase
*, UtilityBase
, 12, Utility
)
25 Duplicates a TagList. The input TagList can be NULL, in which
26 case an empty TagList will be returned.
29 tagList - The TagList that you want to clone
32 A TagList which contains a copy of the TagItems contained in the
33 original list. The list is cloned so that calling FindTagItem()
34 on a tag in the clone will return the same value as that in the
35 original list (assuming the original has not been modified).
40 struct TagItem *tagList, *tagListClone;
42 \* Set up the original taglist tagList *\
44 tagListClone = CloneTagItems( tagList );
46 \* Do what you want with your TagList here *\
48 FreeTagItems( tagListClone );
53 AllocateTagItems(), FreeTagItems(), RefreshTagItemClones()
57 *****************************************************************************/
61 struct TagItem
*newList
;
65 This is rather strange, if we have a NULL input, then we still
66 have to allocate a list. This is to circumvent a bug in SID v2,
67 which for some unknown reason is the only program I have seen
68 that has this problem.
70 Had to alter RefreshTagItemClones as well.
71 However, that is also what the autodoc says...
77 We start the counter at 1 since this count will not include the
80 newList is used here to save a variable. We don't need to do
81 anything to the value of newList afterwards, since AllocateTagItems()
82 will take care of setting it to NULL if the allocation fails.
84 tmp
= (struct TagItem
*)tagList
;
85 while (NextTagItem (&tmp
) != NULL
)
90 Then we shall allocate the TagList.
91 If we can actually allocate a clone tag list, then we shall copy
92 the tag values from one tag to another, the function
93 "RefreshTagItemClones()" is used here to help re-use code.
95 Of course we don't have to worry about the if and only if
96 statement, since the original is guaranteed to have not
97 been changed since CloneTagItems() :)
100 if ((newList
= AllocateTagItems(numTags
)))
101 RefreshTagItemClones(newList
, tagList
);
103 /* newList == 0 when allocation failed - AllocateTagItems handles this*/
107 } /* CloneTagItems */