From b5ec394573ebedea4a7a745ddd3c12c70f3e7095 Mon Sep 17 00:00:00 2001 From: asterix Date: Wed, 1 Sep 2010 10:52:41 +0000 Subject: [PATCH] Add some check utils. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4213 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/struct/bitarray.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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) { -- 2.25.1