Rename xmalloc to pg_malloc for consistency with psql usage.

Add missing plperl include.
This commit is contained in:
Bruce Momjian 2005-07-10 16:13:13 +00:00
parent f86c63ab6a
commit e8a3e6b8a0
3 changed files with 26 additions and 25 deletions

View File

@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * 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 bin_path[MAXPGPATH];
static char backend_exec[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 *xstrdup(const char *s);
static char **replace_token(char **lines, static char **replace_token(char **lines,
const char *token, const char *replacement); const char *token, const char *replacement);
@ -241,7 +241,7 @@ do { \
* rmtree() which needs memory allocation. So we just exit with a bang. * rmtree() which needs memory allocation. So we just exit with a bang.
*/ */
static void * static void *
xmalloc(size_t size) pg_malloc(size_t size)
{ {
void *result; void *result;
@ -288,7 +288,7 @@ replace_token(char **lines, const char *token, const char *replacement)
for (i = 0; lines[i]; i++) for (i = 0; lines[i]; i++)
numlines++; numlines++;
result = (char **) xmalloc(numlines * sizeof(char *)); result = (char **) pg_malloc(numlines * sizeof(char *));
toklen = strlen(token); toklen = strlen(token);
replen = strlen(replacement); 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 */ /* 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]; pre = where - lines[i];
@ -341,7 +341,7 @@ filter_lines_with_token(char **lines, const char *token)
for (i = 0; lines[i]; i++) for (i = 0; lines[i]; i++)
numlines++; numlines++;
result = (char **) xmalloc(numlines * sizeof(char *)); result = (char **) pg_malloc(numlines * sizeof(char *));
for (src = 0, dst = 0; src < numlines; src++) for (src = 0, dst = 0; src < numlines; src++)
{ {
@ -397,8 +397,8 @@ readfile(char *path)
/* set up the result and the line buffer */ /* set up the result and the line buffer */
result = (char **) xmalloc((nlines + 2) * sizeof(char *)); result = (char **) pg_malloc((nlines + 2) * sizeof(char *));
buffer = (char *) xmalloc(maxlength + 2); buffer = (char *) pg_malloc(maxlength + 2);
/* now reprocess the file and store the lines */ /* now reprocess the file and store the lines */
@ -958,7 +958,7 @@ mkdatadir(const char *subdir)
{ {
char *path; char *path;
path = xmalloc(strlen(pg_data) + 2 + path = pg_malloc(strlen(pg_data) + 2 +
(subdir == NULL ? 0 : strlen(subdir))); (subdir == NULL ? 0 : strlen(subdir)));
if (subdir != NULL) if (subdir != NULL)
@ -982,7 +982,7 @@ mkdatadir(const char *subdir)
static void static void
set_input(char **dest, char *filename) 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); sprintf(*dest, "%s/%s", share_path, filename);
} }
@ -1017,12 +1017,12 @@ set_short_version(char *short_version, char *extrapath)
if (extrapath == NULL) if (extrapath == NULL)
{ {
path = xmalloc(strlen(pg_data) + 12); path = pg_malloc(strlen(pg_data) + 12);
sprintf(path, "%s/PG_VERSION", pg_data); sprintf(path, "%s/PG_VERSION", pg_data);
} }
else 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); sprintf(path, "%s/%s/PG_VERSION", pg_data, extrapath);
} }
version_file = fopen(path, PG_BINARY_W); version_file = fopen(path, PG_BINARY_W);
@ -1050,7 +1050,7 @@ set_null_conf(void)
FILE *conf_file; FILE *conf_file;
char *path; char *path;
path = xmalloc(strlen(pg_data) + 17); path = pg_malloc(strlen(pg_data) + 17);
sprintf(path, "%s/postgresql.conf", pg_data); sprintf(path, "%s/postgresql.conf", pg_data);
conf_file = fopen(path, PG_BINARY_W); conf_file = fopen(path, PG_BINARY_W);
if (conf_file == NULL) if (conf_file == NULL)
@ -1989,7 +1989,7 @@ escape_quotes(const char *src)
{ {
int len = strlen(src), int len = strlen(src),
i, j; i, j;
char *result = xmalloc(len * 2 + 1); char *result = pg_malloc(len * 2 + 1);
for (i = 0, j = 0; i < len; i++) 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 * would especially need quotes otherwise on Windows because paths
* there are most likely to have embedded spaces. * 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); sprintf(pgdenv, "PGDATA=%s", pg_data);
putenv(pgdenv); putenv(pgdenv);
@ -2385,7 +2385,7 @@ main(int argc, char *argv[])
if (!share_path) if (!share_path)
{ {
share_path = xmalloc(MAXPGPATH); share_path = pg_malloc(MAXPGPATH);
get_share_path(backend_exec, share_path); get_share_path(backend_exec, share_path);
} }
else if (!is_absolute_path(share_path)) else if (!is_absolute_path(share_path))

View File

@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * 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 /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(printf, 1, 2))); __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 char *xstrdup(const char *s);
static void do_advice(void); static void do_advice(void);
static void do_help(void); static void do_help(void);
@ -191,7 +191,7 @@ write_stderr(const char *fmt,...)
*/ */
static void * static void *
xmalloc(size_t size) pg_malloc(size_t size)
{ {
void *result; void *result;
@ -301,8 +301,8 @@ readfile(const char *path)
maxlength = linelen; maxlength = linelen;
/* set up the result and the line buffer */ /* set up the result and the line buffer */
result = (char **) xmalloc((nlines + 1) * sizeof(char *)); result = (char **) pg_malloc((nlines + 1) * sizeof(char *));
buffer = (char *) xmalloc(maxlength + 1); buffer = (char *) pg_malloc(maxlength + 1);
/* now reprocess the file and store the lines */ /* now reprocess the file and store the lines */
rewind(infile); rewind(infile);
@ -539,7 +539,7 @@ do_start(void)
char *postmaster_path; char *postmaster_path;
int ret; int ret;
postmaster_path = xmalloc(MAXPGPATH); postmaster_path = pg_malloc(MAXPGPATH);
if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR, if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR,
postmaster_path)) < 0) postmaster_path)) < 0)
@ -1353,7 +1353,7 @@ main(int argc, char **argv)
case 'D': case 'D':
{ {
char *pgdata_D; char *pgdata_D;
char *env_var = xmalloc(strlen(optarg) + 8); char *env_var = pg_malloc(strlen(optarg) + 8);
pgdata_D = xstrdup(optarg); pgdata_D = xstrdup(optarg);
canonicalize_path(pgdata_D); canonicalize_path(pgdata_D);
@ -1366,7 +1366,7 @@ main(int argc, char **argv)
* variable but we do -D too for clearer * variable but we do -D too for clearer
* postmaster 'ps' display * 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, snprintf(pgdata_opt, strlen(pgdata_D) + 7,
"-D \"%s\" ", "-D \"%s\" ",
pgdata_D); pgdata_D);

View File

@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * 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 "perl.h"
#include "XSUB.h" #include "XSUB.h"
#include "ppport.h" #include "ppport.h"
#include "spi_internal.h"
/* just in case these symbols aren't provided */ /* just in case these symbols aren't provided */
#ifndef pTHX_ #ifndef pTHX_