Commit 9a7d49d1 authored by Bruce Momjian's avatar Bruce Momjian

Move pg_dump memory routines into pg_dumpmem.c/h and restore common.c

with its original functions.  The previous function migration would
cause too many difficulties in back-patching.
parent efb0423c
......@@ -20,7 +20,7 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_files.o pg_backup_null.o pg_backup_tar.o \
pg_backup_directory.o common.o dumputils.o compress_io.o $(WIN32RES)
pg_backup_directory.o dumpmem.o dumputils.o compress_io.o $(WIN32RES)
KEYWRDOBJS = keywords.o kwlookup.o
......@@ -29,8 +29,8 @@ kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
all: pg_dump pg_restore pg_dumpall
pg_dump: pg_dump.o dumpcatalog.o pg_dump_sort.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
$(CC) $(CFLAGS) pg_dump.o dumpcatalog.o pg_dump_sort.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
$(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
pg_restore: pg_restore.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
$(CC) $(CFLAGS) pg_restore.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
......
This diff is collapsed.
......@@ -53,7 +53,7 @@
*/
#include "compress_io.h"
#include "common.h"
#include "dumpmem.h"
/*----------------------
* Compressor API
......
This diff is collapsed.
/*-------------------------------------------------------------------------
*
* dumpmem.c
* memory routines used by pg_dump and pg_restore (but not pg_dumpall
* because there is no failure location to report).
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/bin/pg_dump/dumpmem.c
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "pg_backup.h"
#include "dumpmem.h"
#include <ctype.h>
/*
* Safer versions of some standard C library functions. If an
* out-of-memory condition occurs, these functions will bail out
* safely; therefore, their return value is guaranteed to be non-NULL.
* We also report the program name and close the database connection.
*/
char *
pg_strdup(const char *string)
{
char *tmp;
if (!string)
exit_horribly(NULL, NULL, "cannot duplicate null pointer\n");
tmp = strdup(string);
if (!tmp)
exit_horribly(NULL, NULL, "out of memory\n");
return tmp;
}
void *
pg_malloc(size_t size)
{
void *tmp;
tmp = malloc(size);
if (!tmp)
exit_horribly(NULL, NULL, "out of memory\n");
return tmp;
}
void *
pg_calloc(size_t nmemb, size_t size)
{
void *tmp;
tmp = calloc(nmemb, size);
if (!tmp)
exit_horribly(NULL, NULL, _("out of memory\n"));
return tmp;
}
void *
pg_realloc(void *ptr, size_t size)
{
void *tmp;
tmp = realloc(ptr, size);
if (!tmp)
exit_horribly(NULL, NULL, _("out of memory\n"));
return tmp;
}
/*-------------------------------------------------------------------------
*
* common.h
* Common header file for the pg_dump, pg_dumpall, and pg_restore
* dumpmem.h
* Common header file for the pg_dump and pg_restore
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/bin/pg_dump/common.h
* src/bin/pg_dump/dumpmem.h
*
*-------------------------------------------------------------------------
*/
#ifndef COMMON_H
#define COMMON_H
#ifndef DUMPMEM_H
#define DUMPMEM_H
#include "postgres_fe.h"
......@@ -21,4 +21,4 @@ extern void *pg_malloc(size_t size);
extern void *pg_calloc(size_t nmemb, size_t size);
extern void *pg_realloc(void *ptr, size_t size);
#endif /* COMMON_H */
#endif /* DUMPMEM_H */
......@@ -16,7 +16,7 @@
#include <ctype.h>
#include "common.h"
#include "dumpmem.h"
#include "dumputils.h"
#include "parser/keywords.h"
......
......@@ -21,7 +21,7 @@
*/
#include "pg_backup_db.h"
#include "common.h"
#include "dumpmem.h"
#include "dumputils.h"
#include <ctype.h>
......
......@@ -25,7 +25,7 @@
*/
#include "compress_io.h"
#include "common.h"
#include "dumpmem.h"
/*--------
* Routines in the format interface
......
......@@ -11,7 +11,7 @@
*/
#include "pg_backup_db.h"
#include "common.h"
#include "dumpmem.h"
#include "dumputils.h"
#include <unistd.h>
......
......@@ -34,7 +34,7 @@
*/
#include "compress_io.h"
#include "common.h"
#include "dumpmem.h"
#include <dirent.h>
#include <sys/stat.h>
......
......@@ -26,7 +26,7 @@
*/
#include "pg_backup_archiver.h"
#include "common.h"
#include "dumpmem.h"
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te);
......
......@@ -23,7 +23,7 @@
*/
#include "pg_backup_archiver.h"
#include "common.h"
#include "dumpmem.h"
#include "dumputils.h"
#include <unistd.h> /* for dup */
......
......@@ -28,7 +28,7 @@
#include "pg_backup.h"
#include "pg_backup_archiver.h"
#include "pg_backup_tar.h"
#include "common.h"
#include "dumpmem.h"
#include <sys/stat.h>
#include <ctype.h>
......
......@@ -57,7 +57,7 @@
#include "libpq/libpq-fs.h"
#include "pg_backup_archiver.h"
#include "common.h"
#include "dumpmem.h"
#include "dumputils.h"
extern char *optarg;
......
......@@ -14,7 +14,7 @@
*-------------------------------------------------------------------------
*/
#include "pg_backup_archiver.h"
#include "common.h"
#include "dumpmem.h"
static const char *modulename = gettext_noop("sorter");
......
......@@ -39,7 +39,7 @@
*-------------------------------------------------------------------------
*/
#include "common.h"
#include "dumpmem.h"
#include "pg_backup_archiver.h"
#include "dumputils.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment