Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
a3823623
...
a382362346aa2ec5700d53411081f0d8161b53af
authored
2003-08-21 16:20:50 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(list_insert): New function.
1 parent
25d8229f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
include/mailutils/list.h
mailbox/list.c
include/mailutils/list.h
View file @
a382362
...
...
@@ -28,6 +28,7 @@ extern int list_create __P ((list_t *));
extern
void
list_destroy
__P
((
list_t
*
));
extern
int
list_append
__P
((
list_t
,
void
*
item
));
extern
int
list_prepend
__P
((
list_t
,
void
*
item
));
extern
int
list_insert
__P
((
list_t
list
,
void
*
item
,
void
*
new_item
));
extern
int
list_is_empty
__P
((
list_t
));
extern
int
list_count
__P
((
list_t
,
size_t
*
pcount
));
extern
int
list_remove
__P
((
list_t
,
void
*
item
));
...
...
mailbox/list.c
View file @
a382362
...
...
@@ -154,6 +154,50 @@ def_comp (const void *item, const void *value)
}
int
list_insert
(
list_t
list
,
void
*
item
,
void
*
new_item
)
{
struct
list_data
*
current
;
list_comparator_t
comp
;
int
status
=
ENOENT
;
if
(
list
==
NULL
)
return
EINVAL
;
comp
=
list
->
comp
?
list
->
comp
:
def_comp
;
monitor_wrlock
(
list
->
monitor
);
for
(
current
=
list
->
head
.
next
;
current
!=
&
(
list
->
head
);
current
=
current
->
next
)
{
if
(
comp
(
current
->
item
,
item
)
==
0
)
{
struct
list_data
*
ldata
=
calloc
(
sizeof
(
*
ldata
),
1
);
if
(
ldata
==
NULL
)
return
ENOMEM
;
ldata
->
item
=
new_item
;
ldata
->
next
=
current
->
next
;
ldata
->
prev
=
current
;
if
(
current
->
next
)
current
->
next
->
prev
=
ldata
;
else
list
->
head
.
prev
=
ldata
;
if
(
current
==
list
->
head
.
next
)
current
=
list
->
head
.
next
=
ldata
;
else
current
->
next
=
ldata
;
list
->
count
++
;
status
=
0
;
break
;
}
}
monitor_unlock
(
list
->
monitor
);
return
status
;
}
int
list_remove
(
list_t
list
,
void
*
item
)
{
struct
list_data
*
current
,
*
previous
;
...
...
Please
register
or
sign in
to post a comment