Index: doc/src/sgml/libpq.sgml =================================================================== RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpq.sgml,v retrieving revision 1.115 diff -c -c -r1.115 libpq.sgml *** doc/src/sgml/libpq.sgml 24 Mar 2003 18:33:52 -0000 1.115 --- doc/src/sgml/libpq.sgml 25 Mar 2003 02:40:07 -0000 *************** *** 1049,1056 **** PQescapeString performs this operation. ! 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 --- 1049,1055 ---- PQescapeString performs this operation. ! 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,1123 **** PQescapeBytea returns an escaped version of the ! from parameter binary string in memory allocated with malloc(). 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 --- 1116,1124 ---- PQescapeBytea returns an escaped version of the ! 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,1150 **** 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. --- 1144,1154 ---- 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. The memory must be ! freed using PQfreemem(). ! *************** *** 1161,1167 **** Frees memory allocated by libpq, particularly ! PQescapeBytea and PQunescapeBytea. It is needed by Win32, which can not free memory across DLL's, unless multithreaded DLL's (/MD in VC6) are used. --- 1165,1173 ---- Frees memory allocated by libpq, particularly ! 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,1932 **** } PGnotify; After processing a PGnotify object returned by PQnotifies, ! be sure to free it with free() to avoid a memory leak. --- 1932,1938 ---- } PGnotify; After processing a PGnotify object returned by PQnotifies, ! be sure to free it with PQfreemem(). *************** *** 2867,2873 **** fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); ! free(notify); } } --- 2873,2879 ---- fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); ! PQfreemem(notify); } } Index: src/bin/psql/common.c =================================================================== RCS file: /cvsroot/pgsql-server/src/bin/psql/common.c,v retrieving revision 1.61 diff -c -c -r1.61 common.c *** src/bin/psql/common.c 20 Mar 2003 15:39:52 -0000 1.61 --- src/bin/psql/common.c 25 Mar 2003 02:40:08 -0000 *************** *** 441,447 **** { fprintf(pset.queryFout, gettext("Asynchronous NOTIFY '%s' from backend with pid %d received.\n"), notify->relname, notify->be_pid); ! free(notify); fflush(pset.queryFout); } } --- 441,447 ---- { fprintf(pset.queryFout, gettext("Asynchronous NOTIFY '%s' from backend with pid %d received.\n"), notify->relname, notify->be_pid); ! PQfreemem(notify); fflush(pset.queryFout); } } Index: src/interfaces/ecpg/ecpglib/execute.c =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/ecpglib/execute.c,v retrieving revision 1.4 diff -c -c -r1.4 execute.c *** src/interfaces/ecpg/ecpglib/execute.c 20 Mar 2003 15:56:50 -0000 1.4 --- src/interfaces/ecpg/ecpglib/execute.c 25 Mar 2003 02:40:10 -0000 *************** *** 1197,1203 **** { ECPGlog("ECPGexecute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n", stmt->lineno, notify->relname, notify->be_pid); ! ECPGfree(notify); } return status; --- 1197,1203 ---- { ECPGlog("ECPGexecute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n", stmt->lineno, notify->relname, notify->be_pid); ! PQfreemem(notify); } return status; Index: src/interfaces/libpgtcl/pgtclId.c =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/libpgtcl/pgtclId.c,v retrieving revision 1.40 diff -c -c -r1.40 pgtclId.c *** src/interfaces/libpgtcl/pgtclId.c 1 Feb 2003 00:22:12 -0000 1.40 --- src/interfaces/libpgtcl/pgtclId.c 25 Mar 2003 02:40:11 -0000 *************** *** 554,560 **** if (event->connid == NULL) { if (event->notify) ! PQfreeNotify(event->notify); return 1; } --- 554,560 ---- if (event->connid == NULL) { if (event->notify) ! PQfreemem(event->notify); return 1; } *************** *** 634,640 **** Tcl_Release((ClientData) event->connid); if (event->notify) ! PQfreeNotify(event->notify); return 1; } --- 634,640 ---- Tcl_Release((ClientData) event->connid); if (event->notify) ! PQfreemem(event->notify); return 1; } Index: src/interfaces/libpq/fe-exec.c =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v retrieving revision 1.127 diff -c -c -r1.127 fe-exec.c *** src/interfaces/libpq/fe-exec.c 22 Mar 2003 03:29:06 -0000 1.127 --- src/interfaces/libpq/fe-exec.c 25 Mar 2003 02:40:15 -0000 *************** *** 1578,1597 **** } /* - * PQfreeNotify - free's the memory associated with a PGnotify - * - * This function is needed on Windows when using libpq.dll and - * for example libpgtcl.dll: All memory allocated inside a dll - * should be freed in the context of the same dll. - * - */ - void - PQfreeNotify(PGnotify *notify) - { - free(notify); - } - - /* * PQgetline - gets a newline-terminated string from the backend. * * Chiefly here so that applications can use "COPY to stdout" --- 1578,1583 ---- *************** *** 2470,2472 **** --- 2456,2477 ---- { return pqSendSome(conn); } + + /* + * PQfreeNotify - free's the memory associated with a PGnotify + * + * This function is here only for binary backward compatibility. + * New code should use PQfreemem(). A macro will automatically map + * calls to PQfreemem. It should be removed in the future. bjm 2003-03-24 + */ + + #undef PQfreeNotify + void PQfreeNotify(PGnotify *notify); + + void + PQfreeNotify(PGnotify *notify) + { + PQfreemem(notify); + } + + Index: src/interfaces/libpq/libpq-fe.h =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/libpq-fe.h,v retrieving revision 1.90 diff -c -c -r1.90 libpq-fe.h *** src/interfaces/libpq/libpq-fe.h 22 Mar 2003 03:29:06 -0000 1.90 --- src/interfaces/libpq/libpq-fe.h 25 Mar 2003 02:40:16 -0000 *************** *** 260,266 **** /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); ! extern void PQfreeNotify(PGnotify *notify); /* Interface for multiple-result or asynchronous queries */ extern int PQsendQuery(PGconn *conn, const char *query); --- 260,267 ---- /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); ! /* Exists for backward compatibility. bjm 2003-03-24 */ ! #define PQfreeNotify(ptr) PQfreemem(ptr) /* Interface for multiple-result or asynchronous queries */ extern int PQsendQuery(PGconn *conn, const char *query); Index: src/interfaces/python/pgmodule.c =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/python/pgmodule.c,v retrieving revision 1.44 diff -c -c -r1.44 pgmodule.c *** src/interfaces/python/pgmodule.c 10 Mar 2003 22:28:22 -0000 1.44 --- src/interfaces/python/pgmodule.c 25 Mar 2003 02:40:18 -0000 *************** *** 2066,2072 **** } PyTuple_SET_ITEM(notify_result, 1, temp); ! free(notify); } else { --- 2066,2072 ---- } PyTuple_SET_ITEM(notify_result, 1, temp); ! PQfreemem(notify); } else { Index: src/test/examples/testlibpq2.c =================================================================== RCS file: /cvsroot/pgsql-server/src/test/examples/testlibpq2.c,v retrieving revision 1.7 diff -c -c -r1.7 testlibpq2.c *** src/test/examples/testlibpq2.c 7 Feb 1999 22:08:54 -0000 1.7 --- src/test/examples/testlibpq2.c 25 Mar 2003 02:40:18 -0000 *************** *** 98,104 **** fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); ! free(notify); break; } PQclear(res); --- 98,104 ---- fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); ! PQfreemem(notify); break; } PQclear(res);