tupletable pnm_alloctupletable(const struct pam * const pamP, unsigned int const size) { tupletable retval; const char * error; alloctupletable(pamP, size, &retval, &error); if (error) { strfree(error); pm_error("Failed to allocation tuple table of size %u", size); } return retval; }
tupletable pnm_alloctupletable(const struct pam * const pamP, unsigned int const size) { tupletable retval; const char * error; alloctupletable(pamP, size, &retval, &error); if (error) { pm_errormsg("%s", error); strfree(error); pm_longjmp(); } return retval; }
static tupletable tuplehashtotable(const struct pam * const pamP, tuplehash const tuplehash, unsigned int const allocsize) { /*---------------------------------------------------------------------------- Create a tuple table containing the info from a tuple hash. Allocate space in the table for 'allocsize' elements even if there aren't that many tuple values in the input hash. That's so the caller has room for expansion. Caller must ensure that 'allocsize' is at least as many tuple values as there are in the input hash. We allocate new space for all the table contents; there are no pointers in the table to tuples or anything else in existing space. -----------------------------------------------------------------------------*/ tupletable tupletable; const char * error; alloctupletable(pamP, allocsize, &tupletable, &error); if (error) { pm_errormsg("%s", error); strfree(error); pm_longjmp(); } else { unsigned int i, j; /* Loop through the hash table. */ j = 0; for (i = 0; i < HASH_SIZE; ++i) { /* Walk this hash chain */ struct tupleint_list_item * p; for (p = tuplehash[i]; p; p = p->next) { assert(j < allocsize); tupletable[j]->value = p->tupleint.value; pnm_assigntuple(pamP, tupletable[j]->tuple, p->tupleint.tuple); ++j; } } } return tupletable; }