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

Commitbdae05f

Browse files
committed
Use calloc() to allocate empty structures.
Fix pg_restore tar log output bug where Special flag wasn't beinginitialized; bug seen on XP.
1 parentb8382c2 commitbdae05f

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

‎src/bin/pg_dump/pg_backup_custom.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.25 2003/08/04 00:43:27 momjian Exp $
22+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.26 2003/10/08 03:52:32 momjian Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -136,7 +136,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
136136
/*
137137
* Set up some special context used in compressing data.
138138
*/
139-
ctx= (lclContext*)malloc(sizeof(lclContext));
139+
ctx= (lclContext*)calloc(1,sizeof(lclContext));
140140
if (ctx==NULL)
141141
die_horribly(AH,modulename,"out of memory\n");
142142
AH->formatData= (void*)ctx;
@@ -253,7 +253,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
253253

254254
if (ctx==NULL)
255255
{
256-
ctx= (lclTocEntry*)malloc(sizeof(lclTocEntry));
256+
ctx= (lclTocEntry*)calloc(1,sizeof(lclTocEntry));
257257
te->formatData= (void*)ctx;
258258
}
259259

‎src/bin/pg_dump/pg_backup_files.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* IDENTIFICATION
23-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.21 2002/10/25 01:33:17 momjian Exp $
23+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.22 2003/10/08 03:52:32 momjian Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -101,7 +101,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
101101
/*
102102
* Set up some special context used in compressing data.
103103
*/
104-
ctx= (lclContext*)malloc(sizeof(lclContext));
104+
ctx= (lclContext*)calloc(1,sizeof(lclContext));
105105
AH->formatData= (void*)ctx;
106106
ctx->filePos=0;
107107

@@ -167,7 +167,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
167167
lclTocEntry*ctx;
168168
charfn[K_STD_BUF_SIZE];
169169

170-
ctx= (lclTocEntry*)malloc(sizeof(lclTocEntry));
170+
ctx= (lclTocEntry*)calloc(1,sizeof(lclTocEntry));
171171
if (te->dataDumper)
172172
{
173173
#ifdefHAVE_LIBZ
@@ -206,7 +206,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
206206

207207
if (ctx==NULL)
208208
{
209-
ctx= (lclTocEntry*)malloc(sizeof(lclTocEntry));
209+
ctx= (lclTocEntry*)calloc(1,sizeof(lclTocEntry));
210210
te->formatData= (void*)ctx;
211211
}
212212

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.37 2003/08/04 00:43:27 momjian Exp $
19+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.38 2003/10/08 03:52:32 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -158,10 +158,11 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
158158
/*
159159
* Set up some special context used in compressing data.
160160
*/
161-
ctx= (lclContext*)malloc(sizeof(lclContext));
161+
ctx= (lclContext*)calloc(1,sizeof(lclContext));
162162
AH->formatData= (void*)ctx;
163163
ctx->filePos=0;
164-
164+
ctx->isSpecialScript=0;
165+
165166
/* Initialize LO buffering */
166167
AH->lo_buf_size=LOBBUFSIZE;
167168
AH->lo_buf= (void*)malloc(LOBBUFSIZE);
@@ -253,7 +254,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
253254
lclTocEntry*ctx;
254255
charfn[K_STD_BUF_SIZE];
255256

256-
ctx= (lclTocEntry*)malloc(sizeof(lclTocEntry));
257+
ctx= (lclTocEntry*)calloc(1,sizeof(lclTocEntry));
257258
if (te->dataDumper!=NULL)
258259
{
259260
#ifdefHAVE_LIBZ
@@ -292,7 +293,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
292293

293294
if (ctx==NULL)
294295
{
295-
ctx= (lclTocEntry*)malloc(sizeof(lclTocEntry));
296+
ctx= (lclTocEntry*)calloc(1,sizeof(lclTocEntry));
296297
te->formatData= (void*)ctx;
297298
}
298299

‎src/bin/pg_dump/pg_dump.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.352 2003/09/27 22:10:01 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.353 2003/10/08 03:52:32 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -1078,7 +1078,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
10781078
write_msg(NULL,"preparing to dump the contents of table %s\n",
10791079
classname);
10801080

1081-
dumpCtx= (DumpContext*)malloc(sizeof(DumpContext));
1081+
dumpCtx= (DumpContext*)calloc(1,sizeof(DumpContext));
10821082
dumpCtx->tblinfo= (TableInfo*)tblinfo;
10831083
dumpCtx->tblidx=i;
10841084
dumpCtx->oids=oids;
@@ -1938,9 +1938,7 @@ getFuncs(int *numFuncs)
19381938

19391939
*numFuncs=ntups;
19401940

1941-
finfo= (FuncInfo*)malloc(ntups*sizeof(FuncInfo));
1942-
1943-
memset((char*)finfo,0,ntups*sizeof(FuncInfo));
1941+
finfo= (FuncInfo*)calloc(ntups,sizeof(FuncInfo));
19441942

19451943
i_oid=PQfnumber(res,"oid");
19461944
i_proname=PQfnumber(res,"proname");
@@ -2144,8 +2142,7 @@ getTables(int *numTables)
21442142
* dumping only one, because we don't yet know which tables might be
21452143
* inheritance ancestors of the target table.
21462144
*/
2147-
tblinfo= (TableInfo*)malloc(ntups*sizeof(TableInfo));
2148-
memset(tblinfo,0,ntups*sizeof(TableInfo));
2145+
tblinfo= (TableInfo*)calloc(ntups,sizeof(TableInfo));
21492146

21502147
i_reloid=PQfnumber(res,"oid");
21512148
i_relname=PQfnumber(res,"relname");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp