- Fixed potential memory leaks and use of freed memory.
[AROS.git] / rom / task / LockTaskList.c
blob8a9a3b83040bfd5223e344a579d12c8f0f6a5003
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
8 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <aros/libcall.h>
11 #include <proto/utility.h>
12 #include <resources/task.h>
14 #include <resources/task.h>
16 #include "taskres_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/task.h>
23 AROS_LH1(struct TaskList *, LockTaskList,
25 /* SYNOPSIS */
26 AROS_LHA(ULONG, flags, D1),
28 /* LOCATION */
29 struct TaskResBase *, TaskResBase, 1, Task)
31 /* FUNCTION
33 INPUTS
34 flags -
36 RESULT
37 Handle to the task list. This is not a direct pointer
38 to the first list element but to a pseudo element instead.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 UnLockTaskList(), NextTaskEntry().
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 struct TaskListPrivate *taskList = NULL;
57 D(bug("[TaskRes] LockTaskList: flags = $%lx\n", flags));
59 if ((taskList = AllocMem(sizeof(struct TaskListPrivate), MEMF_CLEAR)) != NULL)
61 taskList->tlp_Tasks = &TaskResBase->trb_TaskList;
62 taskList->tlp_Next = (struct TaskListEntry *)GetHead(taskList->tlp_Tasks);
63 AddTail(&TaskResBase->trb_LockedLists, &taskList->tlp_Node);
66 return (struct TaskList *)taskList;
68 AROS_LIBFUNC_EXIT
69 } /* LockTaskList */