- for (next_bit = 0, bits_left = length;
- bits_left;
- next_bit += nr_bits, bits_left -= nr_bits)
- { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
- value = cmos_read_bits(&where, nr_bits);
- put_bits(value, next_bit, nr_bits, &result);
+ if (e->config == CMOS_ENTRY_STRING)
+ { char *newstring = malloc((length+7)/8);
+ unsigned usize = (8 * sizeof(unsigned long long));
+
+ if(!newstring) { out_of_memory(); }
+
+ for (next_bit = 0, bits_left = length;
+ bits_left;
+ next_bit += nr_bits, bits_left -= nr_bits)
+ { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left>usize?usize:bits_left, &where);
+ value = cmos_read_bits(&where, nr_bits);
+ put_bits(value, next_bit % usize, nr_bits, &((unsigned long long *)newstring)[next_bit/usize]);
+ result = (unsigned long)newstring;
+ }
+ }
+ else
+ { for (next_bit = 0, bits_left = length;
+ bits_left;
+ next_bit += nr_bits, bits_left -= nr_bits)
+ { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
+ value = cmos_read_bits(&where, nr_bits);
+ put_bits(value, next_bit, nr_bits, &result);
+ }