diff options
author | Neil Conway | 2004-09-22 05:12:45 +0000 |
---|---|---|
committer | Neil Conway | 2004-09-22 05:12:45 +0000 |
commit | 6d228ea56d52388c8f573150c0670734c70a537e (patch) | |
tree | d2a3dc0735861afd350b6f87eed3dd05f73ea457 | |
parent | 220da89974b24595de629ca81919e8ac789cdb68 (diff) |
Minor cleanup of libpq/LO examples: fix some memory leaks, update a comment
or two.
-rw-r--r-- | src/test/examples/testlibpq.c | 2 | ||||
-rw-r--r-- | src/test/examples/testlibpq4.c | 14 | ||||
-rw-r--r-- | src/test/examples/testlo.c | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c index 1f447b33c3..f650118a29 100644 --- a/src/test/examples/testlibpq.c +++ b/src/test/examples/testlibpq.c @@ -1,7 +1,7 @@ /* * testlibpq.c * - * Test the C version of LIBPQ, the POSTGRES frontend library. + * Test the C version of libpq, the PostgreSQL frontend library. */ #include <stdio.h> #include <stdlib.h> diff --git a/src/test/examples/testlibpq4.c b/src/test/examples/testlibpq4.c index 57b5f56ff5..0eda55352e 100644 --- a/src/test/examples/testlibpq4.c +++ b/src/test/examples/testlibpq4.c @@ -92,8 +92,8 @@ main(int argc, char **argv) } /* - * should PQclear PGresult whenever it is no longer needed to avoid - * memory leaks + * make sure to PQclear() a PGresult whenever it is no longer + * needed to avoid memory leaks */ PQclear(res1); @@ -106,7 +106,7 @@ main(int argc, char **argv) { fprintf(stderr, "DECLARE CURSOR command failed\n"); PQclear(res1); - exit_nicely(conn1, NULL); + exit_nicely(conn1, conn2); } PQclear(res1); @@ -115,7 +115,7 @@ main(int argc, char **argv) { fprintf(stderr, "FETCH ALL command didn't return tuples properly\n"); PQclear(res1); - exit_nicely(conn1, NULL); + exit_nicely(conn1, conn2); } /* first, print out the attribute names */ @@ -142,10 +142,10 @@ main(int argc, char **argv) res1 = PQexec(conn1, "END"); PQclear(res1); - /* close the connection to the database and cleanup */ + /* close the connections to the database and cleanup */ PQfinish(conn1); + PQfinish(conn2); /* fclose(debug); */ - return 0; /* Though PQfinish(conn1) has called - * exit(1) */ + return 0; } diff --git a/src/test/examples/testlo.c b/src/test/examples/testlo.c index 23c343fe7f..1f764bfbc0 100644 --- a/src/test/examples/testlo.c +++ b/src/test/examples/testlo.c @@ -99,6 +99,7 @@ pickout(PGconn *conn, Oid lobjId, int start, int len) if (nbytes <= 0) break; /* no more data? */ } + free(buf); fprintf(stderr, "\n"); lo_close(conn, lobj_fd); } @@ -134,6 +135,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len) break; } } + free(buf); fprintf(stderr, "\n"); lo_close(conn, lobj_fd); } |