C function accepting/returning cstring vs. text - Mailing list pgsql-hackers

From Ivan Sergio Borgonovo
Subject C function accepting/returning cstring vs. text
Date
Msg-id 20100125205051.30bd2403@dawn.webthatworks.it
Whole thread Raw
Responses Re: C function accepting/returning cstring vs. text  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
I'm having a hard time trying to understand how everything should be
done in C extensions.

Now I'm trying to understand how and when I should accept/return
cstring vs text and if and how I should take care of any encoding.

I'm trying to output the content of a tsvector as a set of record
pos, weight, text|cstring
I've found tsvectorout that should be enough "educational".
But I still miss details about when/why use cstrings vs. text and
encoding.

Is there any part of the code from where I could learn about:
- memory allocation for both cstring and text
- example of returning text (especially if size of out>in)
- what should I take care of for encoding (what's really inside a tsvector, text, cstring)?

I don't know if pgsql-hackers is the right place to ask and if this
kind of questions are considered "homework" but without any
reference and knowledge of the code base it's pretty hard even to
find prototype/sample code.

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Review: Typed Table
Next
From: Tim Bunce
Date:
Subject: Re: Package namespace and Safe init cleanup for plperl [PATCH]