This can be simplified to `newprev = xrealloc(prev, prevsize);`