4242 * Portions Copyright (c) 1994, Regents of the University of California
4343 * Portions taken from FreeBSD.
4444 *
45- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.91 2005/07/07 20:39:59 tgl Exp $
45+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.92 2005/07/10 16:13:12 momjian Exp $
4646 *
4747 *-------------------------------------------------------------------------
4848 */
@@ -144,7 +144,7 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on
144144static char bin_path [MAXPGPATH ];
145145static char backend_exec [MAXPGPATH ];
146146
147- static void * xmalloc (size_t size );
147+ static void * pg_malloc (size_t size );
148148static char * xstrdup (const char * s );
149149static char * * replace_token (char * * lines ,
150150const char * token ,const char * replacement );
@@ -241,7 +241,7 @@ do { \
241241 * rmtree() which needs memory allocation. So we just exit with a bang.
242242 */
243243static void *
244- xmalloc (size_t size )
244+ pg_malloc (size_t size )
245245{
246246void * result ;
247247
@@ -288,7 +288,7 @@ replace_token(char **lines, const char *token, const char *replacement)
288288for (i = 0 ;lines [i ];i ++ )
289289numlines ++ ;
290290
291- result = (char * * )xmalloc (numlines * sizeof (char * ));
291+ result = (char * * )pg_malloc (numlines * sizeof (char * ));
292292
293293toklen = strlen (token );
294294replen = strlen (replacement );
@@ -309,7 +309,7 @@ replace_token(char **lines, const char *token, const char *replacement)
309309
310310/* if we get here a change is needed - set up new line */
311311
312- newline = (char * )xmalloc (strlen (lines [i ])+ diff + 1 );
312+ newline = (char * )pg_malloc (strlen (lines [i ])+ diff + 1 );
313313
314314pre = where - lines [i ];
315315
@@ -341,7 +341,7 @@ filter_lines_with_token(char **lines, const char *token)
341341for (i = 0 ;lines [i ];i ++ )
342342numlines ++ ;
343343
344- result = (char * * )xmalloc (numlines * sizeof (char * ));
344+ result = (char * * )pg_malloc (numlines * sizeof (char * ));
345345
346346for (src = 0 ,dst = 0 ;src < numlines ;src ++ )
347347{
@@ -397,8 +397,8 @@ readfile(char *path)
397397
398398/* set up the result and the line buffer */
399399
400- result = (char * * )xmalloc ((nlines + 2 )* sizeof (char * ));
401- buffer = (char * )xmalloc (maxlength + 2 );
400+ result = (char * * )pg_malloc ((nlines + 2 )* sizeof (char * ));
401+ buffer = (char * )pg_malloc (maxlength + 2 );
402402
403403/* now reprocess the file and store the lines */
404404
@@ -958,7 +958,7 @@ mkdatadir(const char *subdir)
958958{
959959char * path ;
960960
961- path = xmalloc (strlen (pg_data )+ 2 +
961+ path = pg_malloc (strlen (pg_data )+ 2 +
962962 (subdir == NULL ?0 :strlen (subdir )));
963963
964964if (subdir != NULL )
@@ -982,7 +982,7 @@ mkdatadir(const char *subdir)
982982static void
983983set_input (char * * dest ,char * filename )
984984{
985- * dest = xmalloc (strlen (share_path )+ strlen (filename )+ 2 );
985+ * dest = pg_malloc (strlen (share_path )+ strlen (filename )+ 2 );
986986sprintf (* dest ,"%s/%s" ,share_path ,filename );
987987}
988988
@@ -1017,12 +1017,12 @@ set_short_version(char *short_version, char *extrapath)
10171017
10181018if (extrapath == NULL )
10191019{
1020- path = xmalloc (strlen (pg_data )+ 12 );
1020+ path = pg_malloc (strlen (pg_data )+ 12 );
10211021sprintf (path ,"%s/PG_VERSION" ,pg_data );
10221022}
10231023else
10241024{
1025- path = xmalloc (strlen (pg_data )+ strlen (extrapath )+ 13 );
1025+ path = pg_malloc (strlen (pg_data )+ strlen (extrapath )+ 13 );
10261026sprintf (path ,"%s/%s/PG_VERSION" ,pg_data ,extrapath );
10271027}
10281028version_file = fopen (path ,PG_BINARY_W );
@@ -1050,7 +1050,7 @@ set_null_conf(void)
10501050FILE * conf_file ;
10511051char * path ;
10521052
1053- path = xmalloc (strlen (pg_data )+ 17 );
1053+ path = pg_malloc (strlen (pg_data )+ 17 );
10541054sprintf (path ,"%s/postgresql.conf" ,pg_data );
10551055conf_file = fopen (path ,PG_BINARY_W );
10561056if (conf_file == NULL )
@@ -1989,7 +1989,7 @@ escape_quotes(const char *src)
19891989{
19901990int len = strlen (src ),
19911991i ,j ;
1992- char * result = xmalloc (len * 2 + 1 );
1992+ char * result = pg_malloc (len * 2 + 1 );
19931993
19941994for (i = 0 ,j = 0 ;i < len ;i ++ )
19951995{
@@ -2350,7 +2350,7 @@ main(int argc, char *argv[])
23502350 * would especially need quotes otherwise on Windows because paths
23512351 * there are most likely to have embedded spaces.
23522352 */
2353- pgdenv = xmalloc (8 + strlen (pg_data ));
2353+ pgdenv = pg_malloc (8 + strlen (pg_data ));
23542354sprintf (pgdenv ,"PGDATA=%s" ,pg_data );
23552355putenv (pgdenv );
23562356
@@ -2385,7 +2385,7 @@ main(int argc, char *argv[])
23852385
23862386if (!share_path )
23872387{
2388- share_path = xmalloc (MAXPGPATH );
2388+ share_path = pg_malloc (MAXPGPATH );
23892389get_share_path (backend_exec ,share_path );
23902390}
23912391else if (!is_absolute_path (share_path ))