How do I set the G-code buffer size on Marlin?
Marlin does allow one to change the size of the buffers, in Configuration_adv.h. In the current version there's an ifdef that switches between two cases, one with SD support, and the other without. Both have a movement planner of size 16, which can be adjusted.

Additionally, in the same file, BUFSIZE can be changed to modify the size of the buffer storing unparsed commands before they are parsed and enter the movement planner buffer.

Additionally, for some firmwares, M112 will immediately shut down the printer, no matter what is in the buffer, but the reset button will need to be used, and the axes will not be homed afterward. In Marlin, it's hardcoded to call kill().