@@ -295,7 +295,7 @@ static void *threadRun(void *arg);
295
295
* routines to check mem allocations and fail noisily.
296
296
*/
297
297
static void *
298
- xmalloc (size_t size )
298
+ pg_malloc (size_t size )
299
299
{
300
300
void * result ;
301
301
@@ -309,7 +309,7 @@ xmalloc(size_t size)
309
309
}
310
310
311
311
static void *
312
- xrealloc (void * ptr , size_t size )
312
+ pg_realloc (void * ptr , size_t size )
313
313
{
314
314
void * result ;
315
315
@@ -323,7 +323,7 @@ xrealloc(void *ptr, size_t size)
323
323
}
324
324
325
325
static char *
326
- xstrdup (const char * s )
326
+ pg_strdup (const char * s )
327
327
{
328
328
char * result ;
329
329
@@ -574,17 +574,17 @@ putVariable(CState *st, const char *context, char *name, char *value)
574
574
}
575
575
576
576
if (st -> variables )
577
- newvars = (Variable * ) xrealloc (st -> variables ,
577
+ newvars = (Variable * ) pg_realloc (st -> variables ,
578
578
(st -> nvariables + 1 ) * sizeof (Variable ));
579
579
else
580
- newvars = (Variable * ) xmalloc (sizeof (Variable ));
580
+ newvars = (Variable * ) pg_malloc (sizeof (Variable ));
581
581
582
582
st -> variables = newvars ;
583
583
584
584
var = & newvars [st -> nvariables ];
585
585
586
- var -> name = xstrdup (name );
587
- var -> value = xstrdup (value );
586
+ var -> name = pg_strdup (name );
587
+ var -> value = pg_strdup (value );
588
588
589
589
st -> nvariables ++ ;
590
590
@@ -596,7 +596,7 @@ putVariable(CState *st, const char *context, char *name, char *value)
596
596
char * val ;
597
597
598
598
/* dup then free, in case value is pointing at this variable */
599
- val = xstrdup (value );
599
+ val = pg_strdup (value );
600
600
601
601
free (var -> value );
602
602
var -> value = val ;
@@ -618,7 +618,7 @@ parseVariable(const char *sql, int *eaten)
618
618
if (i == 1 )
619
619
return NULL ;
620
620
621
- name = xmalloc (i );
621
+ name = pg_malloc (i );
622
622
memcpy (name , & sql [1 ], i - 1 );
623
623
name [i - 1 ] = '\0' ;
624
624
@@ -635,7 +635,7 @@ replaceVariable(char **sql, char *param, int len, char *value)
635
635
{
636
636
size_t offset = param - * sql ;
637
637
638
- * sql = xrealloc (* sql , strlen (* sql ) - len + valueln + 1 );
638
+ * sql = pg_realloc (* sql , strlen (* sql ) - len + valueln + 1 );
639
639
param = * sql + offset ;
640
640
}
641
641
@@ -971,7 +971,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile)
971
971
{
972
972
char * sql ;
973
973
974
- sql = xstrdup (command -> argv [0 ]);
974
+ sql = pg_strdup (command -> argv [0 ]);
975
975
sql = assignVariables (st , sql );
976
976
977
977
if (debug )
@@ -1496,7 +1496,7 @@ parseQuery(Command *cmd, const char *raw_sql)
1496
1496
char * sql ,
1497
1497
* p ;
1498
1498
1499
- sql = xstrdup (raw_sql );
1499
+ sql = pg_strdup (raw_sql );
1500
1500
cmd -> argc = 1 ;
1501
1501
1502
1502
p = sql ;
@@ -1558,8 +1558,8 @@ process_commands(char *buf)
1558
1558
return NULL ;
1559
1559
1560
1560
/* 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 );
1563
1563
my_commands -> command_num = num_commands ++ ;
1564
1564
my_commands -> type = 0 ; /* until set */
1565
1565
my_commands -> argc = 0 ;
@@ -1573,7 +1573,7 @@ process_commands(char *buf)
1573
1573
1574
1574
while (tok != NULL )
1575
1575
{
1576
- my_commands -> argv [j ++ ] = xstrdup (tok );
1576
+ my_commands -> argv [j ++ ] = pg_strdup (tok );
1577
1577
my_commands -> argc ++ ;
1578
1578
tok = strtok (NULL , delim );
1579
1579
}
@@ -1675,7 +1675,7 @@ process_commands(char *buf)
1675
1675
switch (querymode )
1676
1676
{
1677
1677
case QUERY_SIMPLE :
1678
- my_commands -> argv [0 ] = xstrdup (p );
1678
+ my_commands -> argv [0 ] = pg_strdup (p );
1679
1679
my_commands -> argc ++ ;
1680
1680
break ;
1681
1681
case QUERY_EXTENDED :
@@ -1709,7 +1709,7 @@ process_file(char *filename)
1709
1709
}
1710
1710
1711
1711
alloc_num = COMMANDS_ALLOC_NUM ;
1712
- my_commands = (Command * * ) xmalloc (sizeof (Command * ) * alloc_num );
1712
+ my_commands = (Command * * ) pg_malloc (sizeof (Command * ) * alloc_num );
1713
1713
1714
1714
if (strcmp (filename , "-" ) == 0 )
1715
1715
fd = stdin ;
@@ -1735,7 +1735,7 @@ process_file(char *filename)
1735
1735
if (lineno >= alloc_num )
1736
1736
{
1737
1737
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 );
1739
1739
}
1740
1740
}
1741
1741
fclose (fd );
@@ -1758,7 +1758,7 @@ process_builtin(char *tb)
1758
1758
int alloc_num ;
1759
1759
1760
1760
alloc_num = COMMANDS_ALLOC_NUM ;
1761
- my_commands = (Command * * ) xmalloc (sizeof (Command * ) * alloc_num );
1761
+ my_commands = (Command * * ) pg_malloc (sizeof (Command * ) * alloc_num );
1762
1762
1763
1763
lineno = 0 ;
1764
1764
@@ -1789,7 +1789,7 @@ process_builtin(char *tb)
1789
1789
if (lineno >= alloc_num )
1790
1790
{
1791
1791
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 );
1793
1793
}
1794
1794
}
1795
1795
@@ -1961,7 +1961,7 @@ main(int argc, char **argv)
1961
1961
else if ((env = getenv ("PGUSER" )) != NULL && * env != '\0' )
1962
1962
login = env ;
1963
1963
1964
- state = (CState * ) xmalloc (sizeof (CState ));
1964
+ state = (CState * ) pg_malloc (sizeof (CState ));
1965
1965
memset (state , 0 , sizeof (CState ));
1966
1966
1967
1967
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)
2184
2184
2185
2185
if (nclients > 1 )
2186
2186
{
2187
- state = (CState * ) xrealloc (state , sizeof (CState ) * nclients );
2187
+ state = (CState * ) pg_realloc (state , sizeof (CState ) * nclients );
2188
2188
memset (state + 1 , 0 , sizeof (CState ) * (nclients - 1 ));
2189
2189
2190
2190
/* copy any -D switch values to all clients */
@@ -2308,7 +2308,7 @@ main(int argc, char **argv)
2308
2308
}
2309
2309
2310
2310
/* set up thread data structures */
2311
- threads = (TState * ) xmalloc (sizeof (TState ) * nthreads );
2311
+ threads = (TState * ) pg_malloc (sizeof (TState ) * nthreads );
2312
2312
for (i = 0 ; i < nthreads ; i ++ )
2313
2313
{
2314
2314
TState * thread = & threads [i ];
@@ -2326,9 +2326,9 @@ main(int argc, char **argv)
2326
2326
int t ;
2327
2327
2328
2328
thread -> exec_elapsed = (instr_time * )
2329
- xmalloc (sizeof (instr_time ) * num_commands );
2329
+ pg_malloc (sizeof (instr_time ) * num_commands );
2330
2330
thread -> exec_count = (int * )
2331
- xmalloc (sizeof (int ) * num_commands );
2331
+ pg_malloc (sizeof (int ) * num_commands );
2332
2332
2333
2333
for (t = 0 ; t < num_commands ; t ++ )
2334
2334
{
@@ -2419,7 +2419,7 @@ threadRun(void *arg)
2419
2419
int remains = nstate ; /* number of remaining clients */
2420
2420
int i ;
2421
2421
2422
- result = xmalloc (sizeof (TResult ));
2422
+ result = pg_malloc (sizeof (TResult ));
2423
2423
INSTR_TIME_SET_ZERO (result -> conn_time );
2424
2424
2425
2425
/* open log file if requested */
@@ -2632,7 +2632,7 @@ pthread_create(pthread_t *thread,
2632
2632
fork_pthread * th ;
2633
2633
void * ret ;
2634
2634
2635
- th = (fork_pthread * ) xmalloc (sizeof (fork_pthread ));
2635
+ th = (fork_pthread * ) pg_malloc (sizeof (fork_pthread ));
2636
2636
if (pipe (th -> pipes ) < 0 )
2637
2637
{
2638
2638
free (th );
@@ -2680,7 +2680,7 @@ pthread_join(pthread_t th, void **thread_return)
2680
2680
if (thread_return != NULL )
2681
2681
{
2682
2682
/* assume result is TResult */
2683
- * thread_return = xmalloc (sizeof (TResult ));
2683
+ * thread_return = pg_malloc (sizeof (TResult ));
2684
2684
if (read (th -> pipes [0 ], * thread_return , sizeof (TResult )) != sizeof (TResult ))
2685
2685
{
2686
2686
free (* thread_return );
@@ -2748,7 +2748,7 @@ pthread_create(pthread_t *thread,
2748
2748
int save_errno ;
2749
2749
win32_pthread * th ;
2750
2750
2751
- th = (win32_pthread * ) xmalloc (sizeof (win32_pthread ));
2751
+ th = (win32_pthread * ) pg_malloc (sizeof (win32_pthread ));
2752
2752
th -> routine = start_routine ;
2753
2753
th -> arg = arg ;
2754
2754
th -> result = NULL ;
0 commit comments