mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Add useful smartlist_string_remove function.
svn:r3996
This commit is contained in:
parent
11d20d78a0
commit
ff545c3103
@ -118,6 +118,21 @@ void smartlist_remove(smartlist_t *sl, void *element) {
|
||||
}
|
||||
}
|
||||
|
||||
/** If there are any string in sl equal to element, remove the first.
|
||||
* Does not preserve order. */
|
||||
void
|
||||
smartlist_string_remove(smartlist_t *sl, const char *element)
|
||||
{
|
||||
int i;
|
||||
size_t len = smartlist_len(sl);
|
||||
for (i = 0; i < len; ++i) {
|
||||
if (!strcmp(element, smartlist_get(sl, i))) {
|
||||
smartlist_del(sl, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Return true iff some element E of sl has E==element.
|
||||
*/
|
||||
int smartlist_isin(const smartlist_t *sl, void *element) {
|
||||
|
@ -30,6 +30,7 @@ void smartlist_truncate(smartlist_t *sl, int n);
|
||||
void smartlist_add(smartlist_t *sl, void *element);
|
||||
void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2);
|
||||
void smartlist_remove(smartlist_t *sl, void *element);
|
||||
void smartlist_string_remove(smartlist_t *sl, const char *element);
|
||||
int smartlist_isin(const smartlist_t *sl, void *element);
|
||||
int smartlist_string_isin(const smartlist_t *sl, const char *element);
|
||||
int smartlist_string_num_isin(const smartlist_t *sl, int num);
|
||||
|
Loading…
Reference in New Issue
Block a user