Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ZerXes
Tor
Commits
5458ca39
Commit
5458ca39
authored
Dec 13, 2003
by
Roger Dingledine
Browse files
minor tweaks to the smartlist operations
svn:r903
parent
911f155f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/common/util.c
View file @
5458ca39
...
...
@@ -88,13 +88,19 @@ void smartlist_free(smartlist_t *sl) {
void
smartlist_add
(
smartlist_t
*
sl
,
void
*
element
)
{
if
(
sl
->
num_used
<
sl
->
max
)
sl
->
list
[
sl
->
num_used
++
]
=
element
;
else
log_fn
(
LOG_WARN
,
"We've already got %d elements, discarding."
,
sl
->
max
);
}
void
smartlist_remove
(
smartlist_t
*
sl
,
void
*
element
)
{
int
i
;
if
(
element
==
NULL
)
return
;
for
(
i
=
0
;
i
<
sl
->
num_used
;
i
++
)
if
(
sl
->
list
[
i
]
==
element
)
if
(
sl
->
list
[
i
]
==
element
)
{
sl
->
list
[
i
]
=
sl
->
list
[
--
sl
->
num_used
];
/* swap with the end */
i
--
;
/* so we process the new i'th element */
}
}
void
*
smartlist_choose
(
smartlist_t
*
sl
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment