From e8a3e6b8a05ae0c7ad0aefaaa0767f7a67d1fae2 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 10 Jul 2005 16:13:13 +0000 Subject: [PATCH] Rename xmalloc to pg_malloc for consistency with psql usage. Add missing plperl include. --- src/bin/initdb/initdb.c | 32 ++++++++++++++++---------------- src/bin/pg_ctl/pg_ctl.c | 16 ++++++++-------- src/pl/plperl/plperl.c | 3 ++- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f5ea903ca3..281f247d42 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.91 2005/07/07 20:39:59 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.92 2005/07/10 16:13:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -144,7 +144,7 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on static char bin_path[MAXPGPATH]; static char backend_exec[MAXPGPATH]; -static void *xmalloc(size_t size); +static void *pg_malloc(size_t size); static char *xstrdup(const char *s); static char **replace_token(char **lines, const char *token, const char *replacement); @@ -241,7 +241,7 @@ do { \ * rmtree() which needs memory allocation. So we just exit with a bang. */ static void * -xmalloc(size_t size) +pg_malloc(size_t size) { void *result; @@ -288,7 +288,7 @@ replace_token(char **lines, const char *token, const char *replacement) for (i = 0; lines[i]; i++) numlines++; - result = (char **) xmalloc(numlines * sizeof(char *)); + result = (char **) pg_malloc(numlines * sizeof(char *)); toklen = strlen(token); replen = strlen(replacement); @@ -309,7 +309,7 @@ replace_token(char **lines, const char *token, const char *replacement) /* if we get here a change is needed - set up new line */ - newline = (char *) xmalloc(strlen(lines[i]) + diff + 1); + newline = (char *) pg_malloc(strlen(lines[i]) + diff + 1); pre = where - lines[i]; @@ -341,7 +341,7 @@ filter_lines_with_token(char **lines, const char *token) for (i = 0; lines[i]; i++) numlines++; - result = (char **) xmalloc(numlines * sizeof(char *)); + result = (char **) pg_malloc(numlines * sizeof(char *)); for (src = 0, dst = 0; src < numlines; src++) { @@ -397,8 +397,8 @@ readfile(char *path) /* set up the result and the line buffer */ - result = (char **) xmalloc((nlines + 2) * sizeof(char *)); - buffer = (char *) xmalloc(maxlength + 2); + result = (char **) pg_malloc((nlines + 2) * sizeof(char *)); + buffer = (char *) pg_malloc(maxlength + 2); /* now reprocess the file and store the lines */ @@ -958,7 +958,7 @@ mkdatadir(const char *subdir) { char *path; - path = xmalloc(strlen(pg_data) + 2 + + path = pg_malloc(strlen(pg_data) + 2 + (subdir == NULL ? 0 : strlen(subdir))); if (subdir != NULL) @@ -982,7 +982,7 @@ mkdatadir(const char *subdir) static void set_input(char **dest, char *filename) { - *dest = xmalloc(strlen(share_path) + strlen(filename) + 2); + *dest = pg_malloc(strlen(share_path) + strlen(filename) + 2); sprintf(*dest, "%s/%s", share_path, filename); } @@ -1017,12 +1017,12 @@ set_short_version(char *short_version, char *extrapath) if (extrapath == NULL) { - path = xmalloc(strlen(pg_data) + 12); + path = pg_malloc(strlen(pg_data) + 12); sprintf(path, "%s/PG_VERSION", pg_data); } else { - path = xmalloc(strlen(pg_data) + strlen(extrapath) + 13); + path = pg_malloc(strlen(pg_data) + strlen(extrapath) + 13); sprintf(path, "%s/%s/PG_VERSION", pg_data, extrapath); } version_file = fopen(path, PG_BINARY_W); @@ -1050,7 +1050,7 @@ set_null_conf(void) FILE *conf_file; char *path; - path = xmalloc(strlen(pg_data) + 17); + path = pg_malloc(strlen(pg_data) + 17); sprintf(path, "%s/postgresql.conf", pg_data); conf_file = fopen(path, PG_BINARY_W); if (conf_file == NULL) @@ -1989,7 +1989,7 @@ escape_quotes(const char *src) { int len = strlen(src), i, j; - char *result = xmalloc(len * 2 + 1); + char *result = pg_malloc(len * 2 + 1); for (i = 0, j = 0; i < len; i++) { @@ -2350,7 +2350,7 @@ main(int argc, char *argv[]) * would especially need quotes otherwise on Windows because paths * there are most likely to have embedded spaces. */ - pgdenv = xmalloc(8 + strlen(pg_data)); + pgdenv = pg_malloc(8 + strlen(pg_data)); sprintf(pgdenv, "PGDATA=%s", pg_data); putenv(pgdenv); @@ -2385,7 +2385,7 @@ main(int argc, char *argv[]) if (!share_path) { - share_path = xmalloc(MAXPGPATH); + share_path = pg_malloc(MAXPGPATH); get_share_path(backend_exec, share_path); } else if (!is_absolute_path(share_path)) diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 31547cbbf0..efd325419f 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.58 2005/06/21 04:02:32 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.59 2005/07/10 16:13:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ write_stderr(const char *fmt,...) /* This extension allows gcc to check the format string for consistency with the supplied arguments. */ __attribute__((format(printf, 1, 2))); -static void *xmalloc(size_t size); +static void *pg_malloc(size_t size); static char *xstrdup(const char *s); static void do_advice(void); static void do_help(void); @@ -191,7 +191,7 @@ write_stderr(const char *fmt,...) */ static void * -xmalloc(size_t size) +pg_malloc(size_t size) { void *result; @@ -301,8 +301,8 @@ readfile(const char *path) maxlength = linelen; /* set up the result and the line buffer */ - result = (char **) xmalloc((nlines + 1) * sizeof(char *)); - buffer = (char *) xmalloc(maxlength + 1); + result = (char **) pg_malloc((nlines + 1) * sizeof(char *)); + buffer = (char *) pg_malloc(maxlength + 1); /* now reprocess the file and store the lines */ rewind(infile); @@ -539,7 +539,7 @@ do_start(void) char *postmaster_path; int ret; - postmaster_path = xmalloc(MAXPGPATH); + postmaster_path = pg_malloc(MAXPGPATH); if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR, postmaster_path)) < 0) @@ -1353,7 +1353,7 @@ main(int argc, char **argv) case 'D': { char *pgdata_D; - char *env_var = xmalloc(strlen(optarg) + 8); + char *env_var = pg_malloc(strlen(optarg) + 8); pgdata_D = xstrdup(optarg); canonicalize_path(pgdata_D); @@ -1366,7 +1366,7 @@ main(int argc, char **argv) * variable but we do -D too for clearer * postmaster 'ps' display */ - pgdata_opt = xmalloc(strlen(pgdata_D) + 7); + pgdata_opt = pg_malloc(strlen(pgdata_D) + 7); snprintf(pgdata_opt, strlen(pgdata_D) + 7, "-D \"%s\" ", pgdata_D); diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 836502b7e7..957c7c67a2 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.83 2005/07/10 15:32:47 momjian Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.84 2005/07/10 16:13:13 momjian Exp $ * **********************************************************************/ @@ -61,6 +61,7 @@ #include "perl.h" #include "XSUB.h" #include "ppport.h" +#include "spi_internal.h" /* just in case these symbols aren't provided */ #ifndef pTHX_