Andrew Chernow <ac@esilo.com> writes:
> Tim Hawes wrote:
>> char *e_var = getenv("PGMASTERKEY");
>> size_t length = VARSIZE(e_var) - VARHDRSZ;
> The VARSIZE macro is for variable length structures, like a text or
> bytea which contains a length and data member. You are using this macro
> on a regular C string "e_var".
The code on the output side is wrong too: if the useful data length is
"length", then the palloc has to ask for length + VARHDRSZ, and that's
also what's got to be put into the length word.
regards, tom lane