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
9b7dc272
...
9b7dc2723bd164421d1dc25818a5e3e037eb43d0
authored
2004-01-05 13:50:54 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(list_locate): New function
1 parent
74f72efa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
include/mailutils/list.h
mailbox/list.c
include/mailutils/list.h
View file @
9b7dc27
...
...
@@ -35,6 +35,7 @@ extern int list_remove __P ((list_t, void *item));
extern
int
list_replace
__P
((
list_t
list
,
void
*
old_item
,
void
*
new_item
));
extern
int
list_get
__P
((
list_t
,
size_t
_index
,
void
**
pitem
));
extern
int
list_to_array
__P
((
list_t
list
,
void
**
array
,
size_t
count
,
size_t
*
pcount
));
extern
int
list_locate
__P
((
list_t
list
,
void
*
item
,
void
**
ret_item
));
typedef
int
list_action_t
__PMT
((
void
*
item
,
void
*
cbdata
));
...
...
mailbox/list.c
View file @
9b7dc27
...
...
@@ -156,6 +156,32 @@ def_comp (const void *item, const void *value)
}
int
list_locate
(
list_t
list
,
void
*
item
,
void
**
ret_item
)
{
struct
list_data
*
current
,
*
previous
;
list_comparator_t
comp
;
int
status
=
ENOENT
;
if
(
list
==
NULL
)
return
EINVAL
;
comp
=
list
->
comp
?
list
->
comp
:
def_comp
;
monitor_wrlock
(
list
->
monitor
);
for
(
previous
=
&
(
list
->
head
),
current
=
list
->
head
.
next
;
current
!=
&
(
list
->
head
);
previous
=
current
,
current
=
current
->
next
)
{
if
(
comp
(
current
->
item
,
item
)
==
0
)
{
if
(
ret_item
)
*
ret_item
=
current
->
item
;
status
=
0
;
break
;
}
}
monitor_unlock
(
list
->
monitor
);
return
status
;
}
int
list_insert
(
list_t
list
,
void
*
item
,
void
*
new_item
)
{
struct
list_data
*
current
;
...
...
Please
register
or
sign in
to post a comment