The transfer function hooks into the PostgreSQL accumArrayResult() function (present since 8.0) to build an array in a side memory context.