Rewrote sal_malloc().  Not tested, helper functions missing