Re: [PATCHES] pstrndup()
Karel Zak wrote: On Sun, Mar 21, 2004 at 11:45:18PM -0500, Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Karel, do you plan to use pstrndup for some purpose? I assume so. I thinkPostgreSQL should supports basicoperation with allocation/strings if it's open for users' C functions and we expect our own memory system usage. I am not familiar with strndup. If the spec is like strncpy, I would vote against including it ... strncpy is so broken that we had to invent our own variant ... POSIX strncpy() is different, a result from strncpy needn't be zero terminated. You're right it's horrible function. The result of strndup() is always zero terminated. It's more safe and strndup() is binary safe because it doesn't check something in input string. The pstrndup() is based on PostgreSQL memory managment. Can you find places to use this function our backend? Seems that should be part of the patch. -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
Re: [PATCHES] pstrndup()
Karel, do you plan to use pstrndup for some purpose? I assume so. --- Karel Zak wrote: Hi guys, we have pstrdup(char *string) and this tiny patch adds pstrndup(char *sting, Size len). By the way, I a little played with the apache memory managment and they have the others interesting routines like ap_pstrcat(...) that concatenate all arguments (last must be NULL) to new allocated string. Is something like this interesting for PostgreSQL? Karel -- Karel Zak [EMAIL PROTECTED] http://home.zf.jcu.cz/~zakkr/ [ Attachment, skipping... ] ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
Re: [PATCHES] pstrndup()
Bruce Momjian [EMAIL PROTECTED] writes: Karel, do you plan to use pstrndup for some purpose? I assume so. I am not familiar with strndup. If the spec is like strncpy, I would vote against including it ... strncpy is so broken that we had to invent our own variant ... regards, tom lane ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [PATCHES] pstrndup()
On Sun, Mar 21, 2004 at 11:45:18PM -0500, Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Karel, do you plan to use pstrndup for some purpose? I assume so. I thinkPostgreSQL should supports basicoperation with allocation/strings if it's open for users' C functions and we expect our own memory system usage. I am not familiar with strndup. If the spec is like strncpy, I would vote against including it ... strncpy is so broken that we had to invent our own variant ... POSIX strncpy() is different, a result from strncpy needn't be zero terminated. You're right it's horrible function. The result of strndup() is always zero terminated. It's more safe and strndup() is binary safe because it doesn't check something in input string. The pstrndup() is based on PostgreSQL memory managment. Karel -- Karel Zak [EMAIL PROTECTED] http://home.zf.jcu.cz/~zakkr/ ---(end of broadcast)--- TIP 8: explain analyze is your friend