mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
list: added list_extend()
This commit is contained in:
parent
b0017f859f
commit
1ada9d10d9
2 changed files with 9 additions and 0 deletions
|
@ -134,6 +134,9 @@ int list_set(struct list *l, int index, void *value);
|
|||
*/
|
||||
ssize_t list_index(struct list *l, void *value);
|
||||
|
||||
/** Extend the list to the given length by filling new slots with given value. */
|
||||
void list_extend(struct list *l, size_t len, void *val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -231,3 +231,9 @@ found: pthread_mutex_unlock(&l->lock);
|
|||
|
||||
return f;
|
||||
}
|
||||
|
||||
void list_extend(struct list *l, size_t len, void *val)
|
||||
{
|
||||
while (list_length(l) < len)
|
||||
list_push(l, val);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue