Can we modify 'text *' passed to a C function? - Mailing list pgsql-hackers

From m w
Subject Can we modify 'text *' passed to a C function?
Date
Msg-id 20010205201356.42365.qmail@web12405.mail.yahoo.com
Whole thread Raw
Responses Re: Can we modify 'text *' passed to a C function?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
If I write a function that does a 'tolower()' on each
character of a parameter passed into my function, do I
have to allocate a new text object and initialize it
and copy the data, or can I modify that object in
place and return it?

Modifying it in place will save the overhead of an
alloc call, and on a large database, that could add
up.

right now, I am allocating a new data buffer of
exactly the same size and it seems like a waste.

Secondly, if I modify the data length of an object,
as: VARDATA(field) = nn, making sure that 'nn' is
smaller than the origial length, with this affect the
memory management?

In short, can we modify text * objects passed to a C
function, and can we shrink the length field without
any ill effects?

(Doing so will reduce quite a bit of memory allocation
overhead I am doing.)


__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/


pgsql-hackers by date:

Previous
From: Mathieu Dube
Date:
Subject: with -g and libpq.a ...
Next
From: Peter Eisentraut
Date:
Subject: Re: pg_ctl wish list