finish migrating from arosmesa to mesa3dgl
[AROS.git] / rom / dos / remsegment.c
blob4ae53d8846e280c7accc9d464abe79dfb1b9a932
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Remove a segment from the system list.
6 Lang: English
7 */
9 #include "dos_intern.h"
10 #include <aros/config.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
16 #include <dos/dosextens.h>
17 #include <proto/dos.h>
19 AROS_LH1(LONG, RemSegment,
21 /* SYNOPSIS */
22 AROS_LHA(struct Segment *, seg, D1),
24 /* LOCATION */
25 struct DosLibrary *, DOSBase, 131, Dos)
27 /* FUNCTION
28 Remove the segment seg from the DOS resident command list.
30 The segment to be removed should be in the list, and should
31 have a usercount of 0. System or internal segment cannot be
32 removed (although they can be replaced).
34 INPUTS
35 seg - Segment to remove.
37 RESULT
38 != 0 Segment was removed
39 == 0 Segment was not removed (not in list, or not free).
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 AddSegment(), FindSegment()
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 /* Make sure segment is freeable */
57 #if AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT
58 if (seg->seg_UC == 0 || seg->seg_UC == 1)
59 #else
60 if (seg->seg_UC == 0)
61 #endif
63 struct Segment *next, *prev;
64 struct DosInfo *dinf = BADDR(DOSBase->dl_Root->rn_Info);
66 prev = NULL;
67 next = BADDR(dinf->di_ResList);
68 while (next != NULL)
70 if (next == seg)
72 if (prev)
74 prev->seg_Next = next->seg_Next;
76 else
78 dinf->di_ResList = next->seg_Next;
80 UnLoadSeg(seg->seg_Seg);
81 FreeVec(seg);
82 return DOSTRUE;
85 prev = next;
86 next = BADDR(next->seg_Next);
90 return DOSFALSE;
92 AROS_LIBFUNC_EXIT
93 } /* RemSegment */