"Merlin Moncure" <mmoncure(at)gmail(dot)com> writes:
> Am I doing anything wrong here?
Returning an already-pfree'd hunk of memory. I gather you are not
testing your code in an enable-cassert build (tut tut), else you'd
not think this worked for small allocations either. See
http://developer.postgresql.org/pgdocs/postgres/spi-memory.html
regards, tom lane