Wee, I admit defeat! Redesigning the function was of course trivial after a good night's sleep, and I basically went from:
return create_exp(main_conn->conn, '\0', build_tree(start, main_conn->start), build_tree(main_conn->stop, stop));
/* When doing this, I lost track of main_conn. */
Now I can free everything without further ado. Haha, pretty obvious when I look at it now.
node = create_exp(main_conn->conn, '\0', build_tree(start, main_conn->start), build_tree(main_conn->stop, stop));
By the way, when a function returns, is every locally created variable free()'ed, technically speaking? I mean, I know that they exist only within the function, but is free() equivalent to that auto-destruction?
(I'm sorry about all these stupid questions, but I'm learning C by myself and don't really have anyone to ask. The fact that my C book isn't very in-depth doesn't help. So until I get my next book, please bear with me. )