Re: Q: text palloc() size vs. SET_VARSIZE()

2018-03-05 Thread Albrecht Dreß
Am 04.03.18 20:52 schrieb(en) Tom Lane: > From the docs, for me it is not clear whether the value assigned using SET_VARSIZE() must be the *exact* size of the newly allocated return value, or just the length of the text plus the header size. IOW would the code above create a memory leak if

Re: Q: text palloc() size vs. SET_VARSIZE()

2018-03-04 Thread Tom Lane
Albrecht =?iso-8859-1?b?RHJl3w==?= writes: > text *t = PG_GETARG_TEXT_PP(0); > size_tout_len = 0U; > // allocate to the max. possible output size > text *new_t = (text *) palloc(VARSIZE_ANY_EXHDR(t) + VARHDRSZ); > // copy data to

Q: text palloc() size vs. SET_VARSIZE()

2018-03-04 Thread Albrecht Dreß
Hi all, I have a (hopefully not too dumb) question regarding the size allocation of a text return value in a C user-defined function. Basically, the function is somewhat similar to the copytext() example on . However, the function