This ports a lot of the space checking code into a the common library, so that the DDX and mesa can use it.