Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / remsegment.c
blob43f142af3952752d4fe0812bac385d2d59dc3aa8
1 /*
2 Copyright © 1995-2001, 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 <proto/exec.h>
12 /*****************************************************************************
14 NAME */
15 #include <dos/dosextens.h>
16 #include <proto/dos.h>
18 AROS_LH1(LONG, RemSegment,
20 /* SYNOPSIS */
21 AROS_LHA(struct Segment *, seg, D1),
23 /* LOCATION */
24 struct DosLibrary *, DOSBase, 131, Dos)
26 /* FUNCTION
27 Remove the segment seg from the DOS resident command list.
29 The segment to be removed should be in the list, and should
30 have a usercount of 0. System or internal segment cannot be
31 removed (although they can be replaced).
33 INPUTS
34 seg - Segment to remove.
36 RESULT
37 != 0 Segment was removed
38 == 0 Segment was not removed (not in list, or not free).
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 AddSegment(), FindSegment()
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
54 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
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 prev = NULL;
65 next = BADDR(DOSBase->dl_ResList);
66 while (next != NULL)
68 if (next == seg)
70 if (prev)
72 prev->seg_Next = next->seg_Next;
74 else
76 DOSBase->dl_ResList = MKBADDR(next->seg_Next);
79 return DOSTRUE;
82 prev = next;
83 next = BADDR(next->seg_Next);
87 return DOSFALSE;
89 AROS_LIBFUNC_EXIT
90 } /* RemSegment */