We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 994e189 commit 1f067eaCopy full SHA for 1f067ea
libs/onesize/onesize.c
@@ -137,18 +137,20 @@ void am_onesize_iterate_over_allocated_unsafe(
137
if (num < 0) {
138
num = hnd->ntotal;
139
}
140
+ int iterated = 0;
141
num = AM_MIN(num, hnd->ntotal);
142
- for (int i = 0; i < num; ++i) {
143
+ for (int i = 0; (i < hnd->ntotal) && (iterated < num); ++i) {
144
AM_ASSERT(AM_ALIGNOF_PTR(ptr) >= AM_ALIGNOF_SLIST_ITEM);
145
struct am_slist_item *item = AM_CAST(struct am_slist_item *, ptr);
146
if (am_slist_owns(&hnd->fl, item)) {
147
continue; /* the item is free */
148
149
- cb(ctx, i, (char *)item, hnd->block_size);
150
+ cb(ctx, iterated, (char *)item, hnd->block_size);
151
152
ptr += hnd->block_size;
153
+ ++iterated;
154
155
156
0 commit comments