Replace malloc by allocate