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

Commit8396447

Browse files
committed
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among thevarious frontend programs and backend; this lets us eliminate duplicateimplementations of common routines. We avoid libpgport, because that'sintended as a place for porting issues; per discussion, it seems betterto keep them separate.The first use case, and the only implemented by this patch, is pg_mallocand friends, which many frontend programs were already using.At the same time, we can use this to provide palloc emulation functionsfor the frontend; this way, some palloc-using files in the backend canalso be used by the frontend cleanly. To do this, we change palloc() inthe backend to be a function instead of a macro on top ofMemoryContextAlloc(). This was previously believed to cause loss ofperformance, but this implementation has been tweaked by Tom and Andresso that on modern compilers it provides a slight improvement over theprevious one.This lets us clean up some places that were already withlocalized hacks.Most of the pg_malloc/palloc changes in this patch were authored byAndres Freund. Zoltán Böszörményi also independently provided a form ofthat. libpgcommon infrastructure was authored by Álvaro.
1 parent0cb1fac commit8396447

File tree

59 files changed

+332
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+332
-684
lines changed

‎contrib/oid2name/oid2name.c‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ struct options
5050
/* function prototypes */
5151
staticvoidhelp(constchar*progname);
5252
voidget_opts(int,char**,structoptions*);
53-
void*pg_malloc(size_tsize);
54-
void*pg_realloc(void*ptr,size_tsize);
55-
char*pg_strdup(constchar*str);
5653
voidadd_one_elt(char*eltname,eary*eary);
5754
char*get_comma_elts(eary*eary);
5855
PGconn*sql_conn(structoptions*);
@@ -201,53 +198,6 @@ help(const char *progname)
201198
progname,progname);
202199
}
203200

204-
void*
205-
pg_malloc(size_tsize)
206-
{
207-
void*ptr;
208-
209-
/* Avoid unportable behavior of malloc(0) */
210-
if (size==0)
211-
size=1;
212-
ptr=malloc(size);
213-
if (!ptr)
214-
{
215-
fprintf(stderr,"out of memory\n");
216-
exit(1);
217-
}
218-
returnptr;
219-
}
220-
221-
void*
222-
pg_realloc(void*ptr,size_tsize)
223-
{
224-
void*result;
225-
226-
/* Avoid unportable behavior of realloc(NULL, 0) */
227-
if (ptr==NULL&&size==0)
228-
size=1;
229-
result=realloc(ptr,size);
230-
if (!result)
231-
{
232-
fprintf(stderr,"out of memory\n");
233-
exit(1);
234-
}
235-
returnresult;
236-
}
237-
238-
char*
239-
pg_strdup(constchar*str)
240-
{
241-
char*result=strdup(str);
242-
243-
if (!result)
244-
{
245-
fprintf(stderr,"out of memory\n");
246-
exit(1);
247-
}
248-
returnresult;
249-
}
250-
251201
/*
252202
* add_one_elt
253203
*

‎contrib/pg_upgrade/check.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/check.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/controldata.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/controldata.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/dump.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/dump.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/exec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/exec.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/file.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/function.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/function.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/info.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/info.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

‎contrib/pg_upgrade/option.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/option.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"miscadmin.h"
1313

‎contrib/pg_upgrade/page.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*contrib/pg_upgrade/page.c
88
*/
99

10-
#include"postgres.h"
10+
#include"postgres_fe.h"
1111

1212
#include"pg_upgrade.h"
1313

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp