*-------------------------------------------------------------------------
*/
-#include "pg_backup_archiver.h"
#include "compress_io.h"
+#include "common.h"
/*--------
* Routines in the format interface
AH->DeClonePtr = _DeClone;
/* Set up a private area. */
- ctx = (lclContext *) calloc(1, sizeof(lclContext));
- if (ctx == NULL)
- die_horribly(AH, modulename, "out of memory\n");
+ ctx = (lclContext *) pg_calloc(1, sizeof(lclContext));
AH->formatData = (void *) ctx;
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
- AH->lo_buf = (void *) malloc(LOBBUFSIZE);
- if (AH->lo_buf == NULL)
- die_horribly(AH, modulename, "out of memory\n");
+ AH->lo_buf = (void *) pg_malloc(LOBBUFSIZE);
ctx->filePos = 0;
{
lclTocEntry *ctx;
- ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) pg_calloc(1, sizeof(lclTocEntry));
if (te->dataDumper)
ctx->dataState = K_OFFSET_POS_NOT_SET;
else
static void
_ReadExtraToc(ArchiveHandle *AH, TocEntry *te)
{
- int junk;
lclTocEntry *ctx = (lclTocEntry *) te->formatData;
if (ctx == NULL)
{
- ctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
+ ctx = (lclTocEntry *) pg_calloc(1, sizeof(lclTocEntry));
te->formatData = (void *) ctx;
}
* dump it at all.
*/
if (AH->version < K_VERS_1_7)
- junk = ReadInt(AH);
+ ReadInt(AH);
}
/*
{
if (buf)
free(buf);
- buf = (char *) malloc(blkLen);
+ buf = (char *) pg_malloc(blkLen);
buflen = blkLen;
}
cnt = fread(buf, 1, blkLen, AH->FH);
if (AH->mode == archModeWrite)
die_horribly(AH, modulename, "can only reopen input archives\n");
+
+ /*
+ * These two cases are user-facing errors since they represent unsupported
+ * (but not invalid) use-cases. Word the error messages appropriately.
+ */
if (AH->fSpec == NULL || strcmp(AH->fSpec, "") == 0)
- die_horribly(AH, modulename, "cannot reopen stdin\n");
+ die_horribly(AH, modulename, "parallel restore from stdin is not supported\n");
if (!ctx->hasSeek)
- die_horribly(AH, modulename, "cannot reopen non-seekable file\n");
+ die_horribly(AH, modulename, "parallel restore from non-seekable file is not supported\n");
errno = 0;
tpos = ftello(AH->FH);
{
lclContext *ctx = (lclContext *) AH->formatData;
- AH->formatData = (lclContext *) malloc(sizeof(lclContext));
- if (AH->formatData == NULL)
- die_horribly(AH, modulename, "out of memory\n");
+ AH->formatData = (lclContext *) pg_malloc(sizeof(lclContext));
memcpy(AH->formatData, ctx, sizeof(lclContext));
ctx = (lclContext *) AH->formatData;
if (blkLen > *buflen)
{
free(*buf);
- *buf = (char *) malloc(blkLen);
- if (!(*buf))
- die_horribly(AH, modulename, "out of memory\n");
+ *buf = (char *) pg_malloc(blkLen);
*buflen = blkLen;
}