Type System for Memory Safety