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 ,
150150 const 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{
246246 void * result ;
247247
@@ -288,7 +288,7 @@ replace_token(char **lines, const char *token, const char *replacement)
288288 for (i = 0 ; lines [i ]; i ++ )
289289 numlines ++ ;
290290
291- result = (char * * ) xmalloc (numlines * sizeof (char * ));
291+ result = (char * * ) pg_malloc (numlines * sizeof (char * ));
292292
293293 toklen = strlen (token );
294294 replen = 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
314314 pre = where - lines [i ];
315315
@@ -341,7 +341,7 @@ filter_lines_with_token(char **lines, const char *token)
341341 for (i = 0 ; lines [i ]; i ++ )
342342 numlines ++ ;
343343
344- result = (char * * ) xmalloc (numlines * sizeof (char * ));
344+ result = (char * * ) pg_malloc (numlines * sizeof (char * ));
345345
346346 for (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{
959959 char * path ;
960960
961- path = xmalloc (strlen (pg_data ) + 2 +
961+ path = pg_malloc (strlen (pg_data ) + 2 +
962962 (subdir == NULL ? 0 : strlen (subdir )));
963963
964964 if (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 );
986986 sprintf (* dest , "%s/%s" , share_path , filename );
987987}
988988
@@ -1017,12 +1017,12 @@ set_short_version(char *short_version, char *extrapath)
10171017
10181018 if (extrapath == NULL )
10191019 {
1020- path = xmalloc (strlen (pg_data ) + 12 );
1020+ path = pg_malloc (strlen (pg_data ) + 12 );
10211021 sprintf (path , "%s/PG_VERSION" , pg_data );
10221022 }
10231023 else
10241024 {
1025- path = xmalloc (strlen (pg_data ) + strlen (extrapath ) + 13 );
1025+ path = pg_malloc (strlen (pg_data ) + strlen (extrapath ) + 13 );
10261026 sprintf (path , "%s/%s/PG_VERSION" , pg_data , extrapath );
10271027 }
10281028 version_file = fopen (path , PG_BINARY_W );
@@ -1050,7 +1050,7 @@ set_null_conf(void)
10501050 FILE * conf_file ;
10511051 char * path ;
10521052
1053- path = xmalloc (strlen (pg_data ) + 17 );
1053+ path = pg_malloc (strlen (pg_data ) + 17 );
10541054 sprintf (path , "%s/postgresql.conf" , pg_data );
10551055 conf_file = fopen (path , PG_BINARY_W );
10561056 if (conf_file == NULL )
@@ -1989,7 +1989,7 @@ escape_quotes(const char *src)
19891989{
19901990 int len = strlen (src ),
19911991 i , j ;
1992- char * result = xmalloc (len * 2 + 1 );
1992+ char * result = pg_malloc (len * 2 + 1 );
19931993
19941994 for (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 ));
23542354 sprintf (pgdenv , "PGDATA=%s" , pg_data );
23552355 putenv (pgdenv );
23562356
@@ -2385,7 +2385,7 @@ main(int argc, char *argv[])
23852385
23862386 if (!share_path )
23872387 {
2388- share_path = xmalloc (MAXPGPATH );
2388+ share_path = pg_malloc (MAXPGPATH );
23892389 get_share_path (backend_exec , share_path );
23902390 }
23912391 else if (!is_absolute_path (share_path ))
0 commit comments