builtin/apply: move 'p_context' global into 'struct apply_state'