From f1792b932c574eada6527a87e2489364f700fca4 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 25 Mar 2003 02:44:36 +0000 Subject: Use PQfreemem() consistently, and document its use for Notify. Keep PQfreeNotify() around for binary compatibility. --- doc/src/sgml/libpq.sgml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 43ec1a9bf6a..40d4f1fee9f 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,5 +1,5 @@ @@ -1049,8 +1049,7 @@ characters that are otherwise interpreted specially by the SQL parser. PQescapeString performs this operation. -The -parameter from points to the first character of the string that +The parameter from points to the first character of the string that is to be escaped, and the length parameter counts the number of characters in this string. (A terminating zero byte is neither necessary nor counted.) to shall point to a @@ -1117,7 +1116,9 @@ unsigned char *PQescapeBytea(const unsigned char *from, PQescapeBytea returns an escaped version of the - from parameter binary string in memory allocated with malloc(). + from parameter binary string in memory + allocated with malloc(), and must be freed using + PQfreemem(). The return string has all special characters replaced so that they can be properly processed by the PostgreSQL string literal parser, and the bytea input function. A terminating zero @@ -1143,8 +1144,11 @@ unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length); such as might be returned by PQgetvalue when applied to a bytea column. PQunescapeBytea converts this string representation into its binary representation. - It returns a pointer to a buffer allocated with malloc(), or null on error, and puts the size - of the buffer in to_length. + It returns a pointer to a buffer allocated with + malloc(), or null on error, and puts the size of + the buffer in to_length. The memory must be + freed using PQfreemem(). + @@ -1161,7 +1165,9 @@ void PQfreemem(void *ptr); Frees memory allocated by libpq, particularly - PQescapeBytea and PQunescapeBytea. + PQescapeBytea, + PQunescapeBytea, + and PQnotifies. It is needed by Win32, which can not free memory across DLL's, unless multithreaded DLL's (/MD in VC6) are used. @@ -1926,7 +1932,7 @@ typedef struct pgNotify { } PGnotify; After processing a PGnotify object returned by PQnotifies, -be sure to free it with free() to avoid a memory leak. +be sure to free it with PQfreemem(). @@ -2867,7 +2873,7 @@ main() fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); - free(notify); + PQfreemem(notify); } } -- cgit v1.2.3