refactored to remove all the mallocs

it should now be less likely to leak memory, though at the cost of only
being able to handle an arbitrary compile-time number of addresses (in
    this case 32).  This shouldn't be too much of a problem for the
situation I want to use it in, though.