Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb84788d

Browse files
author
Neil Conway
committed
Minor cleanup of libpq/LO examples: fix some memory leaks, update a comment
or two.
1 parenta94edb4 commitb84788d

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

‎src/test/examples/testlibpq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* testlibpq.c
33
*
4-
*Test the C version ofLIBPQ, thePOSTGRES frontend library.
4+
*Test the C version oflibpq, thePostgreSQL frontend library.
55
*/
66
#include<stdio.h>
77
#include<stdlib.h>

‎src/test/examples/testlibpq4.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ main(int argc, char **argv)
9292
}
9393

9494
/*
95-
*shouldPQclearPGresult whenever it is no longer needed to avoid
96-
* memory leaks
95+
*make sure toPQclear() aPGresult whenever it is no longer
96+
*needed to avoidmemory leaks
9797
*/
9898
PQclear(res1);
9999

@@ -106,7 +106,7 @@ main(int argc, char **argv)
106106
{
107107
fprintf(stderr,"DECLARE CURSOR command failed\n");
108108
PQclear(res1);
109-
exit_nicely(conn1,NULL);
109+
exit_nicely(conn1,conn2);
110110
}
111111
PQclear(res1);
112112

@@ -115,7 +115,7 @@ main(int argc, char **argv)
115115
{
116116
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
117117
PQclear(res1);
118-
exit_nicely(conn1,NULL);
118+
exit_nicely(conn1,conn2);
119119
}
120120

121121
/* first, print out the attribute names */
@@ -142,10 +142,10 @@ main(int argc, char **argv)
142142
res1=PQexec(conn1,"END");
143143
PQclear(res1);
144144

145-
/* close theconnection to the database and cleanup */
145+
/* close theconnections to the database and cleanup */
146146
PQfinish(conn1);
147+
PQfinish(conn2);
147148

148149
/* fclose(debug); */
149-
return0;/* Though PQfinish(conn1) has called
150-
* exit(1) */
150+
return0;
151151
}

‎src/test/examples/testlo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.22 2004/08/29 04:13:12 momjian Exp $
11+
* $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.23 2004/09/22 05:12:45 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -99,6 +99,7 @@ pickout(PGconn *conn, Oid lobjId, int start, int len)
9999
if (nbytes <=0)
100100
break;/* no more data? */
101101
}
102+
free(buf);
102103
fprintf(stderr,"\n");
103104
lo_close(conn,lobj_fd);
104105
}
@@ -134,6 +135,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len)
134135
break;
135136
}
136137
}
138+
free(buf);
137139
fprintf(stderr,"\n");
138140
lo_close(conn,lobj_fd);
139141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp