smalloc: fix int truncation issue