Here's a v2- note on NULL args/returns- ref PointerGetDatum- used your example. Started adding some comments but don't think they'rereally necessary. The reader gets the point as-is I think.