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(const 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()
58 29-10-95 digulla automatically created from
59 utility_lib.fd and clib/utility_protos.h
60 11-08-96 iaint Implemented as AROS function.
61 01-09-96 iaint Updated the docs to give the same warnings
63 05-09-96 iaint Bit of optimisation (one variable :( )
64 23-01-97 iaint Corrected NULL TagList handling.
66 *****************************************************************************/
70 struct TagItem
*newList
;
74 This is rather strange, if we have a NULL input, then we still
75 have to allocate a list. This is to circumvent a bug in SID v2,
76 which for some unknown reason is the only program I have seen
77 that has this problem.
79 Had to alter RefreshTagItemClones as well.
80 However, that is also what the autodoc says...
84 const struct TagItem
*tmp
;
86 We start the counter at 1 since this count will not include the
89 newList is used here to save a variable. We don't need to do
90 anything to the value of newList afterwards, since AllocateTagitems()
91 will take care of setting it to NULL if the allocation fails.
94 while (NextTagItem (&tmp
) != NULL
)
99 Then we shall allocate the TagList.
100 If we can actually allocate a clone tag list, then we shall copy
101 the tag values from one tag to another, the function
102 "RefreshTagItemClones()" is used here to help re-use code.
104 Of course we don't have to worry about the if and only if
105 statement, since the original is guaranteed to have not
106 been changed since CloneTagItems() :)
109 if ((newList
= AllocateTagItems(numTags
)))
110 RefreshTagItemClones(newList
, tagList
);
112 /* newList == 0 when allocation failed - AllocateTagItems handles this*/
116 } /* CloneTagItems */