diff options
Diffstat (limited to 'src/bin/pg_dump')
-rw-r--r-- | src/bin/pg_dump/common.c | 24 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_backup_tar.c | 10 |
2 files changed, 14 insertions, 20 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 794e6e7ce99..395f817fa8f 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -400,7 +400,7 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) if (parentidx == NULL) continue; - attachinfo = (IndexAttachInfo *) pg_malloc(sizeof(IndexAttachInfo)); + attachinfo = pg_malloc_object(IndexAttachInfo); attachinfo->dobj.objType = DO_INDEX_ATTACH; attachinfo->dobj.catId.tableoid = 0; @@ -530,7 +530,7 @@ flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables) { AttrDefInfo *attrDef; - attrDef = (AttrDefInfo *) pg_malloc(sizeof(AttrDefInfo)); + attrDef = pg_malloc_object(AttrDefInfo); attrDef->dobj.objType = DO_ATTRDEF; attrDef->dobj.catId.tableoid = 0; attrDef->dobj.catId.oid = 0; @@ -600,14 +600,12 @@ AssignDumpId(DumpableObject *dobj) if (allocedDumpIds <= 0) { newAlloc = 256; - dumpIdMap = (DumpableObject **) - pg_malloc(newAlloc * sizeof(DumpableObject *)); + dumpIdMap = pg_malloc_array(DumpableObject *, newAlloc); } else { newAlloc = allocedDumpIds * 2; - dumpIdMap = (DumpableObject **) - pg_realloc(dumpIdMap, newAlloc * sizeof(DumpableObject *)); + dumpIdMap = pg_realloc_array(dumpIdMap, DumpableObject *, newAlloc); } memset(dumpIdMap + allocedDumpIds, 0, (newAlloc - allocedDumpIds) * sizeof(DumpableObject *)); @@ -700,8 +698,7 @@ getDumpableObjects(DumpableObject ***objs, int *numObjs) int i, j; - *objs = (DumpableObject **) - pg_malloc(allocedDumpIds * sizeof(DumpableObject *)); + *objs = pg_malloc_array(DumpableObject *, allocedDumpIds); j = 0; for (i = 1; i < allocedDumpIds; i++) { @@ -724,15 +721,13 @@ addObjectDependency(DumpableObject *dobj, DumpId refId) if (dobj->allocDeps <= 0) { dobj->allocDeps = 16; - dobj->dependencies = (DumpId *) - pg_malloc(dobj->allocDeps * sizeof(DumpId)); + dobj->dependencies = pg_malloc_array(DumpId, dobj->allocDeps); } else { dobj->allocDeps *= 2; - dobj->dependencies = (DumpId *) - pg_realloc(dobj->dependencies, - dobj->allocDeps * sizeof(DumpId)); + dobj->dependencies = pg_realloc_array(dobj->dependencies, + DumpId, dobj->allocDeps); } } dobj->dependencies[dobj->nDeps++] = refId; @@ -990,8 +985,7 @@ findParentsByOid(TableInfo *self, if (numParents > 0) { - self->parents = (TableInfo **) - pg_malloc(sizeof(TableInfo *) * numParents); + self->parents = pg_malloc_array(TableInfo *, numParents); j = 0; for (i = 0; i < numInherits; i++) { diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index bfc49b66d2c..7960b81c0e6 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -151,7 +151,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) /* * Set up some special context used in compressing data. */ - ctx = (lclContext *) pg_malloc0(sizeof(lclContext)); + ctx = pg_malloc0_object(lclContext); AH->formatData = (void *) ctx; ctx->filePos = 0; ctx->isSpecialScript = 0; @@ -240,7 +240,7 @@ _ArchiveEntry(ArchiveHandle *AH, TocEntry *te) lclTocEntry *ctx; char fn[K_STD_BUF_SIZE]; - ctx = (lclTocEntry *) pg_malloc0(sizeof(lclTocEntry)); + ctx = pg_malloc0_object(lclTocEntry); if (te->dataDumper != NULL) { snprintf(fn, sizeof(fn), "%d.dat", te->dumpId); @@ -272,7 +272,7 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te) if (ctx == NULL) { - ctx = (lclTocEntry *) pg_malloc0(sizeof(lclTocEntry)); + ctx = pg_malloc0_object(lclTocEntry); te->formatData = (void *) ctx; } @@ -337,7 +337,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) { int old_umask; - tm = pg_malloc0(sizeof(TAR_MEMBER)); + tm = pg_malloc0_object(TAR_MEMBER); /* * POSIX does not require, but permits, tmpfile() to restrict file @@ -1052,7 +1052,7 @@ static TAR_MEMBER * _tarPositionTo(ArchiveHandle *AH, const char *filename) { lclContext *ctx = (lclContext *) AH->formatData; - TAR_MEMBER *th = pg_malloc0(sizeof(TAR_MEMBER)); + TAR_MEMBER *th = pg_malloc0_object(TAR_MEMBER); char c; char header[TAR_BLOCK_SIZE]; size_t i, |