Implemented mem_free func