Wednesday, August 13, 2008

Re: [HACKERS] C Extension woes

Tim Hawes wrote:
>
> text * pl_masterkey(PG_FUNCTION_ARGS)
> {
> 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". Try this instead:

size_t length = e_var != NULL ? strlen(e_var) : 0;

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

No comments: