Can we modify 'text *' passed to a C function?

From: m w <mttf2000(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Can we modify 'text *' passed to a C function?
Date: 2001-02-05 20:13:56
Message-ID: 20010205201356.42365.qmail@web12405.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-02-05 20:26:23 Re: pg_ctl wish list
Previous Message Mathieu Dube 2001-02-05 20:12:23 with -g and libpq.a ...