I have a C array like:
char byte_array[10];
And another one that acts as a mask:
char byte_mask[10];
I would
\#define CHAR_ARRAY_SIZE (10)
\#define INT_ARRAY_SIZE ((CHAR_ARRAY_SIZE/ (sizeof (unsigned int)) + 1)
typedef union _arr_tag_ {
char byte_array [CHAR_ARRAY_SIZE];
unsigned int int_array [INT_ARRAY_SIZE];
} arr_tag;
Now int_array for masking. This might work for both 32bit and 64 bit processors.
arr_tag arr_src, arr_result, arr_mask;
for (int i = 0; i < INT_ARRAY_SIZE; i ++) {
arr_result.int_array [i] = arr_src.int_array[i] & arr_mask.int_array [i];
}
Try this, code might also look clean.