alsa.audio: move handling of XRUN when writting to the slave task
[AROS.git] / rom / utility / clonetagitems.c
blobf367010f0651dd512784167b774c971468b571e5
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CloneTagItems()
6 Lang: english
7 */
8 #include "intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <utility/tagitem.h>
14 #include <proto/utility.h>
16 AROS_LH1(struct TagItem *, CloneTagItems,
18 /* SYNOPSIS */
19 AROS_LHA(struct TagItem *, tagList, A0),
21 /* LOCATION */
22 struct UtilityBase *, UtilityBase, 12, Utility)
24 /* FUNCTION
25 Duplicates a TagList. The input TagList can be NULL, in which
26 case an empty TagList will be returned.
28 INPUTS
29 tagList - The TagList that you want to clone
31 RESULT
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).
37 NOTES
39 EXAMPLE
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 );
50 BUGS
52 SEE ALSO
53 AllocateTagItems(), FreeTagItems(), RefreshTagItemClones()
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct TagItem *newList;
62 LONG numTags = 1;
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...
73 if (tagList)
75 struct TagItem *tmp;
77 We start the counter at 1 since this count will not include the
78 TAG_DONE TagItem
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)
86 numTags++;
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*/
104 return newList;
106 AROS_LIBFUNC_EXIT
107 } /* CloneTagItems */