@@ -295,7 +295,7 @@ static void *threadRun(void *arg);
295295 * routines to check mem allocations and fail noisily.
296296 */
297297static void *
298- xmalloc (size_t size )
298+ pg_malloc (size_t size )
299299{
300300 void * result ;
301301
@@ -309,7 +309,7 @@ xmalloc(size_t size)
309309}
310310
311311static void *
312- xrealloc (void * ptr , size_t size )
312+ pg_realloc (void * ptr , size_t size )
313313{
314314 void * result ;
315315
@@ -323,7 +323,7 @@ xrealloc(void *ptr, size_t size)
323323}
324324
325325static char *
326- xstrdup (const char * s )
326+ pg_strdup (const char * s )
327327{
328328 char * result ;
329329
@@ -574,17 +574,17 @@ putVariable(CState *st, const char *context, char *name, char *value)
574574 }
575575
576576 if (st -> variables )
577- newvars = (Variable * ) xrealloc (st -> variables ,
577+ newvars = (Variable * ) pg_realloc (st -> variables ,
578578 (st -> nvariables + 1 ) * sizeof (Variable ));
579579 else
580- newvars = (Variable * ) xmalloc (sizeof (Variable ));
580+ newvars = (Variable * ) pg_malloc (sizeof (Variable ));
581581
582582 st -> variables = newvars ;
583583
584584 var = & newvars [st -> nvariables ];
585585
586- var -> name = xstrdup (name );
587- var -> value = xstrdup (value );
586+ var -> name = pg_strdup (name );
587+ var -> value = pg_strdup (value );
588588
589589 st -> nvariables ++ ;
590590
@@ -596,7 +596,7 @@ putVariable(CState *st, const char *context, char *name, char *value)
596596 char * val ;
597597
598598 /* dup then free, in case value is pointing at this variable */
599- val = xstrdup (value );
599+ val = pg_strdup (value );
600600
601601 free (var -> value );
602602 var -> value = val ;
@@ -618,7 +618,7 @@ parseVariable(const char *sql, int *eaten)
618618 if (i == 1 )
619619 return NULL ;
620620
621- name = xmalloc (i );
621+ name = pg_malloc (i );
622622 memcpy (name , & sql [1 ], i - 1 );
623623 name [i - 1 ] = '\0' ;
624624
@@ -635,7 +635,7 @@ replaceVariable(char **sql, char *param, int len, char *value)
635635 {
636636 size_t offset = param - * sql ;
637637
638- * sql = xrealloc (* sql , strlen (* sql ) - len + valueln + 1 );
638+ * sql = pg_realloc (* sql , strlen (* sql ) - len + valueln + 1 );
639639 param = * sql + offset ;
640640 }
641641
@@ -971,7 +971,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile)
971971 {
972972 char * sql ;
973973
974- sql = xstrdup (command -> argv [0 ]);
974+ sql = pg_strdup (command -> argv [0 ]);
975975 sql = assignVariables (st , sql );
976976
977977 if (debug )
@@ -1496,7 +1496,7 @@ parseQuery(Command *cmd, const char *raw_sql)
14961496 char * sql ,
14971497 * p ;
14981498
1499- sql = xstrdup (raw_sql );
1499+ sql = pg_strdup (raw_sql );
15001500 cmd -> argc = 1 ;
15011501
15021502 p = sql ;
@@ -1558,8 +1558,8 @@ process_commands(char *buf)
15581558 return NULL ;
15591559
15601560 /* Allocate and initialize Command structure */
1561- my_commands = (Command * ) xmalloc (sizeof (Command ));
1562- my_commands -> line = xstrdup (buf );
1561+ my_commands = (Command * ) pg_malloc (sizeof (Command ));
1562+ my_commands -> line = pg_strdup (buf );
15631563 my_commands -> command_num = num_commands ++ ;
15641564 my_commands -> type = 0 ; /* until set */
15651565 my_commands -> argc = 0 ;
@@ -1573,7 +1573,7 @@ process_commands(char *buf)
15731573
15741574 while (tok != NULL )
15751575 {
1576- my_commands -> argv [j ++ ] = xstrdup (tok );
1576+ my_commands -> argv [j ++ ] = pg_strdup (tok );
15771577 my_commands -> argc ++ ;
15781578 tok = strtok (NULL , delim );
15791579 }
@@ -1675,7 +1675,7 @@ process_commands(char *buf)
16751675 switch (querymode )
16761676 {
16771677 case QUERY_SIMPLE :
1678- my_commands -> argv [0 ] = xstrdup (p );
1678+ my_commands -> argv [0 ] = pg_strdup (p );
16791679 my_commands -> argc ++ ;
16801680 break ;
16811681 case QUERY_EXTENDED :
@@ -1709,7 +1709,7 @@ process_file(char *filename)
17091709 }
17101710
17111711 alloc_num = COMMANDS_ALLOC_NUM ;
1712- my_commands = (Command * * ) xmalloc (sizeof (Command * ) * alloc_num );
1712+ my_commands = (Command * * ) pg_malloc (sizeof (Command * ) * alloc_num );
17131713
17141714 if (strcmp (filename , "-" ) == 0 )
17151715 fd = stdin ;
@@ -1735,7 +1735,7 @@ process_file(char *filename)
17351735 if (lineno >= alloc_num )
17361736 {
17371737 alloc_num += COMMANDS_ALLOC_NUM ;
1738- my_commands = xrealloc (my_commands , sizeof (Command * ) * alloc_num );
1738+ my_commands = pg_realloc (my_commands , sizeof (Command * ) * alloc_num );
17391739 }
17401740 }
17411741 fclose (fd );
@@ -1758,7 +1758,7 @@ process_builtin(char *tb)
17581758 int alloc_num ;
17591759
17601760 alloc_num = COMMANDS_ALLOC_NUM ;
1761- my_commands = (Command * * ) xmalloc (sizeof (Command * ) * alloc_num );
1761+ my_commands = (Command * * ) pg_malloc (sizeof (Command * ) * alloc_num );
17621762
17631763 lineno = 0 ;
17641764
@@ -1789,7 +1789,7 @@ process_builtin(char *tb)
17891789 if (lineno >= alloc_num )
17901790 {
17911791 alloc_num += COMMANDS_ALLOC_NUM ;
1792- my_commands = xrealloc (my_commands , sizeof (Command * ) * alloc_num );
1792+ my_commands = pg_realloc (my_commands , sizeof (Command * ) * alloc_num );
17931793 }
17941794 }
17951795
@@ -1961,7 +1961,7 @@ main(int argc, char **argv)
19611961 else if ((env = getenv ("PGUSER" )) != NULL && * env != '\0' )
19621962 login = env ;
19631963
1964- state = (CState * ) xmalloc (sizeof (CState ));
1964+ state = (CState * ) pg_malloc (sizeof (CState ));
19651965 memset (state , 0 , sizeof (CState ));
19661966
19671967 while ((c = getopt_long (argc , argv , "ih:nvp:dSNc:j:Crs:t:T:U:lf:D:F:M:" , long_options , & optindex )) != -1 )
@@ -2184,7 +2184,7 @@ main(int argc, char **argv)
21842184
21852185 if (nclients > 1 )
21862186 {
2187- state = (CState * ) xrealloc (state , sizeof (CState ) * nclients );
2187+ state = (CState * ) pg_realloc (state , sizeof (CState ) * nclients );
21882188 memset (state + 1 , 0 , sizeof (CState ) * (nclients - 1 ));
21892189
21902190 /* copy any -D switch values to all clients */
@@ -2308,7 +2308,7 @@ main(int argc, char **argv)
23082308 }
23092309
23102310 /* set up thread data structures */
2311- threads = (TState * ) xmalloc (sizeof (TState ) * nthreads );
2311+ threads = (TState * ) pg_malloc (sizeof (TState ) * nthreads );
23122312 for (i = 0 ; i < nthreads ; i ++ )
23132313 {
23142314 TState * thread = & threads [i ];
@@ -2326,9 +2326,9 @@ main(int argc, char **argv)
23262326 int t ;
23272327
23282328 thread -> exec_elapsed = (instr_time * )
2329- xmalloc (sizeof (instr_time ) * num_commands );
2329+ pg_malloc (sizeof (instr_time ) * num_commands );
23302330 thread -> exec_count = (int * )
2331- xmalloc (sizeof (int ) * num_commands );
2331+ pg_malloc (sizeof (int ) * num_commands );
23322332
23332333 for (t = 0 ; t < num_commands ; t ++ )
23342334 {
@@ -2419,7 +2419,7 @@ threadRun(void *arg)
24192419 int remains = nstate ; /* number of remaining clients */
24202420 int i ;
24212421
2422- result = xmalloc (sizeof (TResult ));
2422+ result = pg_malloc (sizeof (TResult ));
24232423 INSTR_TIME_SET_ZERO (result -> conn_time );
24242424
24252425 /* open log file if requested */
@@ -2632,7 +2632,7 @@ pthread_create(pthread_t *thread,
26322632 fork_pthread * th ;
26332633 void * ret ;
26342634
2635- th = (fork_pthread * ) xmalloc (sizeof (fork_pthread ));
2635+ th = (fork_pthread * ) pg_malloc (sizeof (fork_pthread ));
26362636 if (pipe (th -> pipes ) < 0 )
26372637 {
26382638 free (th );
@@ -2680,7 +2680,7 @@ pthread_join(pthread_t th, void **thread_return)
26802680 if (thread_return != NULL )
26812681 {
26822682 /* assume result is TResult */
2683- * thread_return = xmalloc (sizeof (TResult ));
2683+ * thread_return = pg_malloc (sizeof (TResult ));
26842684 if (read (th -> pipes [0 ], * thread_return , sizeof (TResult )) != sizeof (TResult ))
26852685 {
26862686 free (* thread_return );
@@ -2748,7 +2748,7 @@ pthread_create(pthread_t *thread,
27482748 int save_errno ;
27492749 win32_pthread * th ;
27502750
2751- th = (win32_pthread * ) xmalloc (sizeof (win32_pthread ));
2751+ th = (win32_pthread * ) pg_malloc (sizeof (win32_pthread ));
27522752 th -> routine = start_routine ;
27532753 th -> arg = arg ;
27542754 th -> result = NULL ;
0 commit comments