ListDeleteRange
Description
Delete count elements starting at start.
Parameters
| Name | Direction | Description |
|---|---|---|
l |
in,out | List handle. |
start |
in | First deleted index. |
count |
in | Number of elements to delete. |
Success
Returns to the caller. count nodes starting at start are unlinked and freed; list length shrinks by count. When copy_deinit is configured it is invoked on each dropped element.
Failure
Function cannot fail. start + count exceeding length is a caller bug and aborts via LOG_FATAL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ListInt.c:163:
if (ListLen(list) > 0 && start < ListLen(list) && count > 0 && start + count <= ListLen(list)) {
ListDeleteRange(list, start, count);
}
break; result = result && list_matches(GENERIC_LIST(&list), (const int[]) {1, 5}, 2);
ListDeleteRange(&list, 0, 2);
result = result && (ListLen(&list) == 0) && (ListHead(&list) == NULL) && (ListTail(&list) == NULL);
Last updated on