diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /bittorrent/mbtstr/src/cmp.c | |
Diffstat (limited to 'bittorrent/mbtstr/src/cmp.c')
| -rw-r--r-- | bittorrent/mbtstr/src/cmp.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bittorrent/mbtstr/src/cmp.c b/bittorrent/mbtstr/src/cmp.c new file mode 100644 index 0000000..58c12d8 --- /dev/null +++ b/bittorrent/mbtstr/src/cmp.c @@ -0,0 +1,18 @@ +#include <complex.h> +#include <stdbool.h> +#include <string.h> + +#include "mbtstr/view.h" + +int mbt_cview_cmp(struct mbt_cview lhs, struct mbt_cview rhs) +{ + size_t min = lhs.size > rhs.size ? rhs.size : lhs.size; + for (size_t i = 0; i < min; i++) + { + if (lhs.data[i] != rhs.data[i]) + return lhs.data[i] - rhs.data[i]; + } + if (rhs.size == lhs.size) + return 0; + return lhs.size - rhs.size; +} |
