In this loop, you want to keep the offset info for variable length arrays. Allocate a int array of size children.size() to put them in. You'll write them all at the end.