#include "strcalc.h"
#include "xmalloc.h"
+#include "error.h"
/*
* local definitions and macros
static const char small_digits[] = "0123456789abcdef";
char *base_val, *div1_res, *div2_res, *rem_res;
- int counter, nibbles, i, sign;
+ int counter, nibbles, i, sign, mask;
char x;
const char *val = (const char *)value;
/* last nibble must be masked */
if (bits & 3) {
- x = and_table[_val(val[++counter])][bits & 3];
+ mask = zex_digit[bits & 3];
+ x = and_table[_val(val[counter++])][mask];
*(--pos) = digits[_val(x)];
}
/* last nibble must be masked */
if (bits & 3) {
- x = and_table[_val(val[++counter])][bits & 3];
+ mask = zex_digit[bits & 3];
+ x = and_table[_val(val[counter++])][mask];
pos -= 4;
p = binary_table[_val(x)];
/* last nibble must be masked */
if (bits & 3) {
+ mask = zex_digit[bits & 3];
+ div1_res[counter] = and_table[_val(p[counter])][mask];
++counter;
-
- div1_res[counter] = and_table[_val(p[counter])][bits & 3];
}
m = div1_res;
break;
default:
- printf("%i\n", base);
- assert(0);
- return NULL;
+ panic("Unsupported base %d", base);
}
return pos;
}
calc_buffer_size = (precision / 2);
max_value_size = (precision / 4);
- calc_buffer = xmalloc(calc_buffer_size+1 * sizeof(char));
- output_buffer = xmalloc(bit_pattern_size+1 * sizeof(char));
+ calc_buffer = XMALLOCN(char, calc_buffer_size + 1);
+ output_buffer = XMALLOCN(char, bit_pattern_size + 1);
DEBUGPRINTF(("init strcalc: \n\tPRECISION: %d\n\tCALC_BUFFER_SIZE = %d\n\tMAX_VALUE_SIZE = %d\n\tbuffer pointer: %p\n", precision, calc_buffer_size, max_value_size, calc_buffer));
}