From: asterix Date: Wed, 1 Sep 2010 10:52:41 +0000 (+0000) Subject: Add some check utils. X-Git-Tag: 2.6.0~188 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=b5ec394573ebedea4a7a745ddd3c12c70f3e7095;p=bertos.git Add some check utils. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4213 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/struct/bitarray.h b/bertos/struct/bitarray.h index 76899c50..326617a3 100644 --- a/bertos/struct/bitarray.h +++ b/bertos/struct/bitarray.h @@ -116,6 +116,35 @@ INLINE bool bitarray_full(uint8_t *bit_array, size_t len) return 1; } +/* + * Ugly!.. reformat it. + */ +INLINE bool bitarray_blockFull(int idx, int offset, uint8_t *bit_array, size_t len) +{ + ASSERT((size_t)(idx + offset) <= len); + + for (int i = idx; i <= idx + offset; i++) + if (!bitarray_check(i, bit_array, len)) + return 0; + + return 1; +} + + +/* + * Ugly!.. reformat it. + */ +INLINE bool bitarray_blockEmpty(int idx, int offset, uint8_t *bit_array, size_t len) +{ + ASSERT((size_t)(idx + offset) <= len); + + for (int i = idx; i <= idx + offset; i++) + if (bitarray_check(i, bit_array, len)) + return 0; + + return 1; +} + INLINE void bitarray_dump(uint8_t *bit_array, size_t len) {