toolbox

Check-in [da11de00e7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:lib: cleanup jtlst_iter_start()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: da11de00e725f9fc4ac682321c356cbc129b1d54666fa9bd4f6f86846aedbbf9
User & Date: jef 2020-07-23 16:18:00
Context
2020-07-26
19:43
retab: remove superfluous cast check-in: 80086d35a4 user: jef tags: trunk
2020-07-23
16:18
lib: cleanup jtlst_iter_start() check-in: da11de00e7 user: jef tags: trunk
2020-07-19
17:15
retab: cosmetic changes check-in: 31342d5054 user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lib/jtlst.c.

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	void *elem;

	while ((elem = jtlst_pop(list)))
		xfree(elem);
	xfree(list);
}

inline
struct jtlst_iter
jtlst_iter_start(struct jtlst *list)
{
	struct jtlst_node *current = &list->head;

	return (struct jtlst_iter) {list, current};
}

void *
jtlst_iter_next(struct jtlst_iter *iter)
{
	if (iter->current->next == &iter->list->head)
		return NULL;

	iter->current = iter->current->next;

	return (void *) ((char *) iter->current - iter->list->offset);
}







<



<
<
|












56
57
58
59
60
61
62

63
64
65


66
67
68
69
70
71
72
73
74
75
76
77
78
	void *elem;

	while ((elem = jtlst_pop(list)))
		xfree(elem);
	xfree(list);
}


struct jtlst_iter
jtlst_iter_start(struct jtlst *list)
{


	return (struct jtlst_iter) {list, &list->head};
}

void *
jtlst_iter_next(struct jtlst_iter *iter)
{
	if (iter->current->next == &iter->list->head)
		return NULL;

	iter->current = iter->current->next;

	return (void *) ((char *) iter->current - iter->list->offset);
}