Re: Text <-> C string - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Text <-> C string
Date
Msg-id 28064.1206467152@sss.pgh.pa.us
Whole thread Raw
In response to Re: Text <-> C string  ("Brendan Jurd" <direvus@gmail.com>)
Responses Re: Text <-> C string
Re: Text <-> C string
List pgsql-hackers
"Brendan Jurd" <direvus@gmail.com> writes:
> On 26/03/2008, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ... What I think is more useful is
>> a strlcpy()-like function that copies into a caller-supplied buffer
>> of limited size.  For lack of a better idea I propose defining it
>> *exactly* like strlcpy:
>> 
>> extern size_t textlcpy(char *dst, const text *src, size_t siz);

> I'm all for providing a function with this behaviour, but is
> textlcpy() a bit ambiguous?

Fair enough, I'm not wedded to that name.  Search-and-replace is
still easy enough at this point ...

> A text_to_cstring_with_len() or text_to_cstring_limit() might be more
> to the point, and more consistent with the other functions in the
> family.

Hmm.  The thing that's bothering me is that the length is the size
of the *destination*, which is not like cstring_to_text_with_len,
so using a closely similar name might be confusing.  Of those two
I'd go with text_to_cstring_limit.  Another thought that comes to
mind is

void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)

Anyone have other ideas?
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Brendan Jurd"
Date:
Subject: Re: Text <-> C string
Next
From: Kurt Roeckx
Date:
Subject: Re: gcc 4.3 breaks ContribCheck in 8.2 and older.