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

Commit53747f7

Browse files
committed
libpq: Add pqReleaseConnHosts function
In a follow up commit we'll need to free this connhost field in afunction defined in fe-cancel.c, so here we extract the logic to adedicated extern function.Author: Jelte Fennema-Nio <jelte.fennema@microsoft.com>Discussion:https://postgr.es/m/AM5PR83MB0178D3B31CA1B6EC4A8ECC42F7529@AM5PR83MB0178.EURPRD83.prod.outlook.com
1 parentc717525 commit53747f7

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4349,19 +4349,7 @@ freePGconn(PGconn *conn)
43494349
free(conn->events[i].name);
43504350
}
43514351

4352-
/* clean up pg_conn_host structures */
4353-
for (inti=0;i<conn->nconnhost;++i)
4354-
{
4355-
free(conn->connhost[i].host);
4356-
free(conn->connhost[i].hostaddr);
4357-
free(conn->connhost[i].port);
4358-
if (conn->connhost[i].password!=NULL)
4359-
{
4360-
explicit_bzero(conn->connhost[i].password,strlen(conn->connhost[i].password));
4361-
free(conn->connhost[i].password);
4362-
}
4363-
}
4364-
free(conn->connhost);
4352+
pqReleaseConnHosts(conn);
43654353

43664354
free(conn->client_encoding_initial);
43674355
free(conn->events);
@@ -4423,6 +4411,31 @@ freePGconn(PGconn *conn)
44234411
free(conn);
44244412
}
44254413

4414+
/*
4415+
* pqReleaseConnHosts
4416+
* - Free the host list in the PGconn.
4417+
*/
4418+
void
4419+
pqReleaseConnHosts(PGconn*conn)
4420+
{
4421+
if (conn->connhost)
4422+
{
4423+
for (inti=0;i<conn->nconnhost;++i)
4424+
{
4425+
free(conn->connhost[i].host);
4426+
free(conn->connhost[i].hostaddr);
4427+
free(conn->connhost[i].port);
4428+
if (conn->connhost[i].password!=NULL)
4429+
{
4430+
explicit_bzero(conn->connhost[i].password,
4431+
strlen(conn->connhost[i].password));
4432+
free(conn->connhost[i].password);
4433+
}
4434+
}
4435+
free(conn->connhost);
4436+
}
4437+
}
4438+
44264439
/*
44274440
* store_conn_addrinfo
44284441
* - copy addrinfo to PGconn object

‎src/interfaces/libpq/libpq-int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ extern void pqDropConnection(PGconn *conn, bool flushInput);
678678
#if defined(WIN32)&& defined(SIO_KEEPALIVE_VALS)
679679
externintpqSetKeepalivesWin32(pgsocketsock,intidle,intinterval);
680680
#endif
681+
externvoidpqReleaseConnHosts(PGconn*conn);
681682
externintpqPacketSend(PGconn*conn,charpack_type,
682683
constvoid*buf,size_tbuf_len);
683684
externboolpqGetHomeDirectory(char*buf,intbufsize);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp