PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ring.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include "srxfixup_internal.h"
12
13SLink *add_ring_top(SLink *tailp, SLink *elementp)
14{
15 if ( !elementp )
16 {
17 return tailp;
18 }
19 if ( tailp )
20 {
21 elementp->next = tailp->next;
22 tailp->next = elementp;
23 }
24 else
25 {
26 tailp = elementp;
27 elementp->next = elementp;
28 }
29 return tailp;
30}
31
32SLink *add_ring_tail(SLink *tailp, SLink *elementp)
33{
34 SLink *tailpa;
35
36 tailpa = add_ring_top(tailp, elementp);
37 if ( !elementp )
38 {
39 return tailpa;
40 }
41 if ( tailpa )
42 {
43 return tailpa->next;
44 }
45 return 0;
46}
47
48SLink *joint_ring(SLink *tailp, SLink *otherring)
49{
50 SLink *othertop;
51
52 if ( !otherring )
53 {
54 return tailp;
55 }
56 if ( !tailp )
57 {
58 return otherring;
59 }
60 othertop = otherring->next;
61 otherring->next = tailp->next;
62 tailp->next = othertop;
63 return tailp;
64}
65
66SLink *ring_to_liner(SLink *tailp)
67{
68 SLink *top;
69
70 if ( !tailp )
71 {
72 return 0;
73 }
74 top = tailp->next;
75 tailp->next = 0;
76 return top;
77}