]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - VtoyTool/BabyISO/biso_list.c
1 /******************************************************************************
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "biso_list.h"
23 #include "biso_util.h"
25 VOID
BISO_DLL_Init(OUT BISO_DLL_S
*pstList
)
27 pstList
->stHead
.pstNext
= &(pstList
->stHead
);
28 pstList
->stHead
.pstPre
= &(pstList
->stHead
);
29 pstList
->pstTail
= &(pstList
->stHead
);
35 IN BISO_DLL_S
*pstList
,
36 IN BISO_DLL_NODE_S
*pstNode
39 pstList
->pstTail
->pstNext
= pstNode
;
40 pstNode
->pstNext
= NULL
;
41 pstNode
->pstPre
= pstList
->pstTail
;
42 pstList
->pstTail
= pstNode
;
46 VOID
BISO_DLL_DelHead(IN BISO_DLL_S
*pstList
)
48 BISO_DLL_NODE_S
*pstFirst
= BISO_DLL_First(pstList
);
52 if (1 == BISO_DLL_Count(pstList
)) /* 唯一节点 */
54 BISO_DLL_Init(pstList
);
58 pstFirst
->pstNext
->pstPre
= &(pstList
->stHead
);
59 pstList
->stHead
.pstNext
= pstFirst
->pstNext
;
64 VOID
BISO_DLL_DelTail(IN BISO_DLL_S
*pstList
)
66 BISO_DLL_NODE_S
*pstLast
= BISO_DLL_Last(pstList
);
70 if (1 == BISO_DLL_Count(pstList
)) /* 唯一节点 */
72 BISO_DLL_Init(pstList
);
76 pstLast
->pstPre
->pstNext
= NULL
;
77 pstList
->pstTail
= pstLast
->pstPre
;
83 VOID
BISO_DLL_Free(IN BISO_DLL_S
*pstList
)
85 BISO_DLL_NODE_S
*pstFirst
= BISO_DLL_First(pstList
);
87 while (NULL
!= pstFirst
)
90 BISO_DLL_DelHead(pstList
);
94 pstFirst
= BISO_DLL_First(pstList
);