Feature #665 ยป 0092-bitvector.c-Replace-parameter-checking-fc_asserts-wi.patch
utility/bitvector.c | ||
---|---|---|
***************************************************************************/
|
||
bool dbv_isset(const struct dbv *pdbv, int bit)
|
||
{
|
||
fc_assert_ret_val(pdbv != nullptr, FALSE);
|
||
fc_assert_ret_val(pdbv->vec != nullptr, FALSE);
|
||
fc_assert_ret_val(bit < pdbv->bits, FALSE);
|
||
... | ... | |
***************************************************************************/
|
||
bool dbv_isset_any(const struct dbv *pdbv)
|
||
{
|
||
fc_assert_ret_val(pdbv != nullptr, FALSE);
|
||
fc_assert_ret_val(pdbv->vec != nullptr, FALSE);
|
||
return bv_check_mask(pdbv->vec, pdbv->vec, _BV_BYTES(pdbv->bits),
|
||
... | ... | |
***************************************************************************/
|
||
void dbv_set(struct dbv *pdbv, int bit)
|
||
{
|
||
fc_assert_ret(pdbv != nullptr);
|
||
fc_assert_ret(pdbv->vec != nullptr);
|
||
fc_assert_ret(bit < pdbv->bits);
|
||
... | ... | |
***************************************************************************/
|
||
void dbv_set_all(struct dbv *pdbv)
|
||
{
|
||
fc_assert_ret(pdbv != nullptr);
|
||
fc_assert_ret(pdbv->vec != nullptr);
|
||
memset(pdbv->vec, 0xff, _BV_BYTES(pdbv->bits));
|
||
... | ... | |
***************************************************************************/
|
||
void dbv_clr(struct dbv *pdbv, int bit)
|
||
{
|
||
fc_assert_ret(pdbv != nullptr);
|
||
fc_assert_ret(pdbv->vec != nullptr);
|
||
fc_assert_ret(bit < pdbv->bits);
|
||
... | ... | |
***************************************************************************/
|
||
void dbv_clr_all(struct dbv *pdbv)
|
||
{
|
||
fc_assert_ret(pdbv != nullptr);
|
||
fc_assert_ret(pdbv->vec != nullptr);
|
||
memset(pdbv->vec, 0, _BV_BYTES(pdbv->bits));
|
||
... | ... | |
***************************************************************************/
|
||
bool dbv_are_equal(const struct dbv *pdbv1, const struct dbv *pdbv2)
|
||
{
|
||
fc_assert_ret_val(pdbv1 != nullptr, FALSE);
|
||
fc_assert_ret_val(pdbv1->vec != nullptr, FALSE);
|
||
fc_assert_ret_val(pdbv2 != nullptr, FALSE);
|
||
fc_assert_ret_val(pdbv2->vec != nullptr, FALSE);
|
||
return bv_are_equal(pdbv1->vec, pdbv2->vec, _BV_BYTES(pdbv1->bits),
|
||
... | ... | |
char test_str[51];
|
||
int i, j, bit;
|
||
fc_assert_ret(pdbv != nullptr);
|
||
fc_assert_ret(pdbv->vec != nullptr);
|
||
for (i = 0; i < (pdbv->bits - 1) / 50 + 1; i++) {
|
utility/bitvector.h | ||
---|---|---|
int dbv_bits(struct dbv *pdbv);
|
||
bool dbv_isset(const struct dbv *pdbv, int bit);
|
||
bool dbv_isset_any(const struct dbv *pdbv);
|
||
void dbv_set(struct dbv *pdbv, int bit);
|
||
void dbv_set_all(struct dbv *pdbv);
|
||
void dbv_clr(struct dbv *pdbv, int bit);
|
||
void dbv_clr_all(struct dbv *pdbv);
|
||
bool dbv_are_equal(const struct dbv *pdbv1, const struct dbv *pdbv2);
|
||
bool dbv_isset(const struct dbv *pdbv, int bit)
|
||
fc__attribute((nonnull (1)));
|
||
bool dbv_isset_any(const struct dbv *pdbv)
|
||
fc__attribute((nonnull (1)));
|
||
void dbv_set(struct dbv *pdbv, int bit)
|
||
fc__attribute((nonnull (1)));
|
||
void dbv_set_all(struct dbv *pdbv)
|
||
fc__attribute((nonnull (1)));
|
||
void dbv_clr(struct dbv *pdbv, int bit)
|
||
fc__attribute((nonnull (1)));
|
||
void dbv_clr_all(struct dbv *pdbv)
|
||
fc__attribute((nonnull (1)));
|
||
bool dbv_are_equal(const struct dbv *pdbv1, const struct dbv *pdbv2)
|
||
fc__attribute((nonnull (1, 2)));
|
||
bool bv_match_dbv(const struct dbv *match, const unsigned char *src);
|
||
void dbv_copy(struct dbv *dest, const struct dbv *src);
|
||
void dbv_to_bv(unsigned char *dest, const struct dbv *src);
|
||
void bv_to_dbv(struct dbv *dest, const unsigned char *src);
|
||
void dbv_debug(struct dbv *pdbv);
|
||
void dbv_debug(struct dbv *pdbv)
|
||
fc__attribute((nonnull (1)));
|
||
/* Maximal size of a dynamic bitvector.
|
||
Use a large value to be on the safe side (4Mbits = 512kbytes). */
|