Avoid manual realloc()

Change-Id: I456a2d29daecf8dee14d109ca39a97c5bf461539