diff options
| author | Tyge Løvset <[email protected]> | 2023-03-12 18:36:58 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-03-12 18:36:58 +0100 |
| commit | 9c4bfa7a3f0afe0f9f293fb4e2042e3babf31467 (patch) | |
| tree | f2193679f55d4fca29d11b0dce1a104183b1f9ac | |
| parent | f68fee2ecc3f03261d983717795079dda01401d7 (diff) | |
| download | STC-modified-9c4bfa7a3f0afe0f9f293fb4e2042e3babf31467.tar.gz STC-modified-9c4bfa7a3f0afe0f9f293fb4e2042e3babf31467.zip | |
Fix warning.
| -rw-r--r-- | include/stc/clist.h | 8 | ||||
| -rw-r--r-- | misc/examples/new_list.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/include/stc/clist.h b/include/stc/clist.h index 9a0c844b..3bab94de 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -386,16 +386,16 @@ STC_DEF int _cx_memb(_sort_cmp_)(const _cx_value* x, const _cx_value* y) { } STC_DEF void _cx_memb(_sort_with)(_cx_self* self, int(*cmp)(const _cx_value*, const _cx_value*)) { - intptr_t len = 0, cap = 0; - _cx_value *a = NULL, *it; + size_t len = 0, cap = 0; + _cx_value *a = NULL, *p; _cx_iter i; for (i = _cx_memb(_begin)(self); i.ref; _cx_memb(_next)(&i)) { if (len == cap) a = (_cx_value *)i_realloc(a, (cap += cap/2 + 4)*sizeof *a); a[len++] = *i.ref; } qsort(a, len, sizeof *a, (int(*)(const void*, const void*))cmp); - for (i = _cx_memb(_begin)(self), it = a; i.ref; _cx_memb(_next)(&i), ++it) - *i.ref = *it; + for (i = _cx_memb(_begin)(self), p = a; i.ref; _cx_memb(_next)(&i), ++p) + *i.ref = *p; i_free(a); } #endif // !c_no_cmp diff --git a/misc/examples/new_list.c b/misc/examples/new_list.c index 6dbe80b4..23709a64 100644 --- a/misc/examples/new_list.c +++ b/misc/examples/new_list.c @@ -11,7 +11,6 @@ struct MyStruct { #define i_val int #define i_opt c_is_forward #define i_tag i32 -#define i_extern // define _clist_mergesort() #include <stc/clist.h> struct Point { int x, y; } typedef Point; @@ -53,6 +52,7 @@ int main() c_forlist (i, float, {123.3f, 321.2f, -32.2f, 78.2f}) clist_float_push_back(&flst, *i.ref); + clist_float_sort(&flst); c_foreach (i, clist_float, flst) printf(" %g", *i.ref); } |
