Example #1
0
bfl_t
sys$bfl_new(vms$pointer size)
{
    bfl_t                   bfl;

    vms$pointer             array_size;
    vms$pointer             i;

    array_size = (size / BITS_PER_BFL_WORD) + 1;

    // Allocate enough space for the header and the bit array needed
    if ((bfl = (bfl_t) sys$alloc(sizeof(struct bfl) + (array_size) *
            sizeof(bfl_word))) == NULL)
    {
        return(NULL);
    }

    bfl->curpos = 0;
    bfl->len = array_size;

    // Set all as allocated
    sys$initmem((vms$pointer) bfl->bitarray, array_size * sizeof(bfl_word));

    // Now free the ones we have
    // FIXME: This is a terribly ineffecient way to do this
    for(i = 0; i < size; i++)
    {
        sys$bfl_free(bfl, i);
    }

    return(bfl);
}
Example #2
0
bfl_t
bfl_new(uintptr_t size)
{
    int i;
    int array_size = (size / BITS_PER_LONG) + 1;

    /* Allocate enough space for the header and the bit array needed */
    bfl_t bfl = malloc(sizeof(struct bfl) + (array_size) * sizeof(bfl_word));

    if (bfl == NULL) {
        return NULL;
    }

    bfl->curpos = 0;
    bfl->len = array_size;
    /* Set all as allocated */
    memset(bfl->bitarray, 0, (array_size) * sizeof(bfl_word));
    /* Now free the ones we have */
    /*
     * FIXME: (benjl) This is a terribly ineffecient way to do this 
     */
    for (i = 0; i < size; i++)
        bfl_free(bfl, i);
    return bfl;
}