diff options
| author | Tyge Løvset <[email protected]> | 2022-10-12 17:56:17 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-10-12 17:56:17 +0200 |
| commit | b2103dc2084f2f0b05645acc7879c9ff5ad84a05 (patch) | |
| tree | 9865c420542cfbe1cb7c5779f2215f8de9fcdfb8 /include/stc/cbits.h | |
| parent | 5fb5ed08250b5ad4eadd6e7a9fdc44f4519b15ff (diff) | |
| download | STC-modified-b2103dc2084f2f0b05645acc7879c9ff5ad84a05.tar.gz STC-modified-b2103dc2084f2f0b05645acc7879c9ff5ad84a05.zip | |
Minor change in cbits print to str.
Diffstat (limited to 'include/stc/cbits.h')
| -rw-r--r-- | include/stc/cbits.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/stc/cbits.h b/include/stc/cbits.h index fcb5808d..10a703e9 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -84,11 +84,12 @@ STC_INLINE size_t _cbits_count(const uint64_t* set, const size_t sz) { } STC_INLINE char* _cbits_to_str(const uint64_t* set, const size_t sz, - char* out, size_t start, intptr_t stop) { - if (stop < 0) - stop = sz; + char* out, size_t start, size_t stop) { + if (stop > sz) stop = sz; + assert(start <= stop); + memset(out, '0', stop - start); - for (intptr_t i = start; i < stop; ++i) + for (size_t i = start; i < stop; ++i) if ((set[i>>6] & _cbits_bit(i)) != 0) out[i - start] = '1'; out[stop - start] = '\0'; @@ -288,7 +289,7 @@ STC_INLINE void _i_memb(_xor)(i_type *self, const i_type* other) { STC_INLINE size_t _i_memb(_count)(const i_type* self) { return _cbits_count(self->data64, _i_memb(_size)(self)); } -STC_INLINE char* _i_memb(_to_str)(const i_type* self, char* out, size_t start, intptr_t stop) +STC_INLINE char* _i_memb(_to_str)(const i_type* self, char* out, size_t start, size_t stop) { return _cbits_to_str(self->data64, _i_memb(_size)(self), out, start, stop); } STC_INLINE bool _i_memb(_subset_of)(const i_type* self, const i_type* other) { |
