2 Copyright (C) 1995 The Free Software Foundation
4 Written by: 1995 Ching Hui (mr854307@cs.nthu.edu.tw)
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License
8 as published by the Free Software Foundation; either version 2 of
9 the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "xdirentry.h"
26 #include "container.h"
32 struct linklist
*head
;
34 head
= g_new (struct linklist
, 1);
36 head
->prev
= head
->next
= head
;
43 linklist_destroy(struct linklist
*head
, void (*destructor
) (void *))
45 struct linklist
*p
, *q
;
47 for (p
= head
->next
; p
!= head
; p
= q
) {
48 if (p
->data
&& destructor
)
49 (*destructor
) (p
->data
);
57 linklist_insert(struct linklist
*head
, void *data
)
61 p
= g_new (struct linklist
, 1);
73 linklist_delete_all(struct linklist
*head
, void (*destructor
) (void *))
75 struct linklist
*p
, *q
;
77 for (p
= head
->next
; p
!= head
; p
= q
) {
82 head
->next
= head
->prev
= head
;
87 linklist_delete(struct linklist
*head
, void *data
)
89 struct linklist
*h
= head
->next
;
92 if (h
->data
== data
) {
93 h
->prev
->next
= h
->next
;
94 h
->next
->prev
= h
->prev
;