Generalize the backing type of bitvec
This commit is contained in:
+5
-6
@@ -1,7 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include "ucore/bitvec.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -14,12 +13,12 @@
|
||||
|
||||
static inline int bit_index(int b)
|
||||
{
|
||||
return b / (sizeof(unsigned long) * CHAR_BIT);
|
||||
return b / (sizeof(uc_bv_integer) * CHAR_BIT);
|
||||
}
|
||||
|
||||
static inline int bit_offset(int b)
|
||||
{
|
||||
return b % (sizeof(unsigned long) * CHAR_BIT);
|
||||
return b % (sizeof(uc_bv_integer) * CHAR_BIT);
|
||||
}
|
||||
|
||||
struct UCBitVec *uc_bv_new(size_t nbits)
|
||||
@@ -29,7 +28,7 @@ struct UCBitVec *uc_bv_new(size_t nbits)
|
||||
if (v == NULL)
|
||||
return NULL;
|
||||
v->vec_len = UC_BV_LEN(nbits);
|
||||
v->vec = malloc(v->vec_len * sizeof(unsigned long));
|
||||
v->vec = malloc(v->vec_len * sizeof(uc_bv_integer));
|
||||
if (v->vec == NULL) {
|
||||
free(v);
|
||||
return NULL;
|
||||
@@ -81,11 +80,11 @@ void uc_bv_set_bits_from_array(struct UCBitVec *v,char *array,size_t array_len)
|
||||
|
||||
void uc_bv_clr_all(struct UCBitVec *v)
|
||||
{
|
||||
memset(v->vec,0, v->vec_len * sizeof(unsigned long));
|
||||
memset(v->vec,0, v->vec_len * sizeof(uc_bv_integer));
|
||||
}
|
||||
|
||||
void uc_bv_set_all(struct UCBitVec *v)
|
||||
{
|
||||
memset(v->vec,0xff,v->vec_len * sizeof(unsigned long));
|
||||
memset(v->vec,0xff,v->vec_len * sizeof(uc_bv_integer));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user