Re: Weird problems with C extension and bytea as input type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Schreyer <ams214(at)cam(dot)ac(dot)uk>
Cc: David W Noon <dwnoon(at)ntlworld(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Weird problems with C extension and bytea as input type
Date: 2011-03-23 14:08:18
Message-ID: 25771.1300889298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Schreyer <ams214(at)cam(dot)ac(dot)uk> writes:
> The actual C++ function looks roughly like this

> extern "C"
> char *function(bytea *b)
> {
> string ism;
> [...]
> return ism.c_str();
> }

My C++ is pretty rusty, but is the pointer returned by c_str() still
valid after the string variable goes out of scope? I'm wondering if you
need a pstrdup before returning.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-03-23 14:11:54 Re: RAID 1 - drive failed - very slow queries even after drive replaced
Previous Message Merlin Moncure 2011-03-23 14:08:00 Re: Weird problems with C extension and bytea as input type