workspace = malloc(sizeof(unsigned short) * x[0]);
workspace = smalloc(sizeof(unsigned short) * x[0]);
char *bignum_decimal(Bignum x) {    int ndigits, ndigit;    int i, iszero;    unsigned long carry;    char *ret;    unsigned short *workspace;    /*     * First, estimate the number of digits. Since log(10)/log(2)     * is just greater than 93/28 (the joys of continued fraction     * approximations...) we know that for every 93 bits, we need     * at most 28 digits. This will tell us how much to malloc.     *     * Formally: if x has i bits, that means x is strictly less     * than 2^i. Since 2 is less than 10^(28/93), this is less than     * 10^(28i/93). We need an integer power of ten, so we must     * round up (rounding down might make it less than x again).     * Therefore if we multiply the bit count by 28/93, rounding     * up, we will have enough digits.     */    i = ssh1_bignum_bitcount(x);    ndigits = (28*i + 92)/93;          /* multiply by 28/93 and round up */    ndigits++;                         /* allow for trailing \0 */    ret = malloc(ndigits);    /*     * Now allocate some workspace to hold the binary form as we     * repeatedly divide it by ten. Initialise this to the     * big-endian form of the number.     */    workspace = malloc(sizeof(unsigned short) * x[0]);    for (i = 0; i < x[0]; i++)        workspace[i] = x[x[0] - i];    /*     * Next, write the decimal number starting with the last digit.     * We use ordinary short division, dividing 10 into the     * workspace.     */    ndigit = ndigits-1;    ret[ndigit] = '\0';    do {        iszero = 1;        carry = 0;        for (i = 0; i < x[0]; i++) {            carry = (carry << 16) + workspace[i];            workspace[i] = (unsigned short) (carry / 10);            if (workspace[i])                iszero = 0;            carry %= 10;        }        ret[--ndigit] = (char)(carry + '0');    } while (!iszero);    /*     * There's a chance we've fallen short of the start of the     * string. Correct if so.     */    if (ndigit > 0)        memmove(ret, ret+ndigit, ndigits-ndigit);    /*     * Done.     */    return ret;}