pk: Move query allocation/deallocation into helper functions
pk: Move query allocation/deallocation into helper functions

- Move code to allocate and deallocate queries into helper functions in
sql.c

- Move query_free() farther down in sql.c

cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr,cmusatyalab/openisr