]> granicus.if.org Git - postgresql/commit - src/bin/psql/common.c
Create libpgcommon, and move pg_malloc et al to it
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 12 Feb 2013 13:33:40 +0000 (10:33 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 12 Feb 2013 14:21:05 +0000 (11:21 -0300)
commit8396447cdbdff0b62914748de2fec04281dc9114
treedd95fd78c6c507ef6f3c9d9c4cd769aeda7c9fcc
parent0cb1fac3b19f01025b63d2cdceabb8767185da28
Create libpgcommon, and move pg_malloc et al to it

libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines.  We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.

The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.

At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly.  To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc().  This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.

This lets us clean up some places that were already with
localized hacks.

Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that.  libpgcommon infrastructure was authored by Álvaro.
59 files changed:
contrib/oid2name/oid2name.c
contrib/pg_upgrade/check.c
contrib/pg_upgrade/controldata.c
contrib/pg_upgrade/dump.c
contrib/pg_upgrade/exec.c
contrib/pg_upgrade/file.c
contrib/pg_upgrade/function.c
contrib/pg_upgrade/info.c
contrib/pg_upgrade/option.c
contrib/pg_upgrade/page.c
contrib/pg_upgrade/parallel.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/relfilenode.c
contrib/pg_upgrade/server.c
contrib/pg_upgrade/tablespace.c
contrib/pg_upgrade/util.c
contrib/pg_upgrade/version.c
contrib/pg_upgrade/version_old_8_3.c
contrib/pgbench/pgbench.c
src/Makefile
src/Makefile.global.in
src/backend/storage/file/copydir.c
src/backend/utils/mmgr/mcxt.c
src/bin/initdb/initdb.c
src/bin/pg_basebackup/streamutil.c
src/bin/pg_basebackup/streamutil.h
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/Makefile
src/bin/pg_dump/common.c
src/bin/pg_dump/compress_io.c
src/bin/pg_dump/dumpmem.c [deleted file]
src/bin/pg_dump/dumpmem.h [deleted file]
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/nls.mk
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_custom.c
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_directory.c
src/bin/pg_dump/pg_backup_null.c
src/bin/pg_dump/pg_backup_tar.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump_sort.c
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_restore.c
src/bin/pg_resetxlog/pg_resetxlog.c
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/scripts/common.c
src/bin/scripts/common.h
src/common/Makefile [new file with mode: 0644]
src/common/fe_memutils.c [new file with mode: 0644]
src/include/common/fe_memutils.h [new file with mode: 0644]
src/include/postgres_fe.h
src/include/utils/palloc.h
src/port/dirmod.c
src/tools/msvc/Install.pm
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Project.pm