Made has_header inline and moved read_char to take a pointer to (uint8 c) to avoid stack stuff. Also, in the last commit I made read_char inline. I call it very often so having it inline seems to make sense.
It works and survives resets. Seems the problem may have been in read_char and it having a local varaiable (uint8 c) - perhaps it was fragmenting memory. I changed it to be in the global scope and now it survives resets. I'll clean the code up and then pass a pointer to c around instead.
send_frame and stomp_login is refactored. Did away with the single frame.header and prefering frame.headers array. Still have weird timing - if I comment lines 203-206 inclusive things get VERY weird...
Remove header_idx from receive_frame and replace it with the more useful (frame->header_count - 1) - i need that in the struct anyways. Also add the beginnings for add_header(), receive_frame will be refactored soon