diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-03-25 02:44:36 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-03-25 02:44:36 +0000 |
commit | f1792b932c574eada6527a87e2489364f700fca4 (patch) | |
tree | 7e7d1f2ff809c2b0542110e68e5cbf5d88715310 /src | |
parent | 6a19c6dccfee66df3970dfba15a8590fdd399bc1 (diff) | |
download | postgresql-f1792b932c574eada6527a87e2489364f700fca4.tar.gz postgresql-f1792b932c574eada6527a87e2489364f700fca4.zip |
Use PQfreemem() consistently, and document its use for Notify.
Keep PQfreeNotify() around for binary compatibility.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/common.c | 4 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 4 | ||||
-rw-r--r-- | src/interfaces/libpgtcl/pgtclId.c | 6 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 35 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 5 | ||||
-rw-r--r-- | src/interfaces/python/pgmodule.c | 2 | ||||
-rw-r--r-- | src/test/examples/testlibpq2.c | 2 |
7 files changed, 32 insertions, 26 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 9f493a4d130..ba6e2954481 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright 2000 by PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.61 2003/03/20 15:39:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.62 2003/03/25 02:44:36 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -441,7 +441,7 @@ PrintNotifications(void) { fprintf(pset.queryFout, gettext("Asynchronous NOTIFY '%s' from backend with pid %d received.\n"), notify->relname, notify->be_pid); - free(notify); + PQfreemem(notify); fflush(pset.queryFout); } } diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 0fdd925a09c..24a46edc415 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.4 2003/03/20 15:56:50 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.5 2003/03/25 02:44:36 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -1197,7 +1197,7 @@ ECPGexecute(struct statement * stmt) { ECPGlog("ECPGexecute line %d: ASYNC NOTIFY of '%s' from backend pid '%d' received\n", stmt->lineno, notify->relname, notify->be_pid); - ECPGfree(notify); + PQfreemem(notify); } return status; diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c index c1b32866d41..7467b024122 100644 --- a/src/interfaces/libpgtcl/pgtclId.c +++ b/src/interfaces/libpgtcl/pgtclId.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.40 2003/02/01 00:22:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.41 2003/03/25 02:44:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -554,7 +554,7 @@ Pg_Notify_EventProc(Tcl_Event *evPtr, int flags) if (event->connid == NULL) { if (event->notify) - PQfreeNotify(event->notify); + PQfreemem(event->notify); return 1; } @@ -634,7 +634,7 @@ Pg_Notify_EventProc(Tcl_Event *evPtr, int flags) Tcl_Release((ClientData) event->connid); if (event->notify) - PQfreeNotify(event->notify); + PQfreemem(event->notify); return 1; } diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 5b8a6d3ef04..9e86b3aa672 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.127 2003/03/22 03:29:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.128 2003/03/25 02:44:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1578,20 +1578,6 @@ PQnotifies(PGconn *conn) } /* - * 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 <rel> to stdout" @@ -2470,3 +2456,22 @@ PQsendSome(PGconn *conn) { 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); +} + + diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index ce9132deb4b..d32b6fdeea3 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.90 2003/03/22 03:29:06 momjian Exp $ + * $Id: libpq-fe.h,v 1.91 2003/03/25 02:44:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -260,7 +260,8 @@ extern void PQfreemem(void *ptr); /* Simple synchronous query */ extern PGresult *PQexec(PGconn *conn, const char *query); extern PGnotify *PQnotifies(PGconn *conn); -extern void PQfreeNotify(PGnotify *notify); +/* 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); diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c index f0194ed0e17..b659c99759e 100644 --- a/src/interfaces/python/pgmodule.c +++ b/src/interfaces/python/pgmodule.c @@ -2066,7 +2066,7 @@ pg_getnotify(pgobject * self, PyObject * args) } PyTuple_SET_ITEM(notify_result, 1, temp); - free(notify); + PQfreemem(notify); } else { diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index 059e39102e2..8f5a1ec3abb 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -98,7 +98,7 @@ main() fprintf(stderr, "ASYNC NOTIFY of '%s' from backend pid '%d' received\n", notify->relname, notify->be_pid); - free(notify); + PQfreemem(notify); break; } PQclear(res); |