Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e10bb05

Browse files
author
Neil Conway
committed
More fallout from the recent psql patch: rename xmalloc and friends to
pg_malloc, to avoid linker failures on same platforms.
1 parent afe7b7b commit e10bb05

12 files changed

+108
-120
lines changed

src/bin/psql/command.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.110 2004/01/24 19:38:49 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.111 2004/01/25 03:07:22 neilc Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -97,7 +97,7 @@ HandleSlashCmds(const char *line,
9797
* backslash command ended */
9898

9999
psql_assert(line);
100-
my_line = xstrdup(line);
100+
my_line = pg_strdup(line);
101101

102102
/*
103103
* Find the first whitespace. line[blank_loc] will now be the
@@ -199,7 +199,7 @@ exec_command(const char *cmd,
199199
* end.
200200
*/
201201
if (options_string)
202-
string = string_cpy = xstrdup(options_string);
202+
string = string_cpy = pg_strdup(options_string);
203203
else
204204
string = string_cpy = NULL;
205205

@@ -497,7 +497,7 @@ exec_command(const char *cmd,
497497
else
498498
{
499499
expand_tilde(&fname);
500-
pset.gfname = xstrdup(fname);
500+
pset.gfname = pg_strdup(fname);
501501
}
502502
free(fname);
503503
status = CMD_SEND;
@@ -693,7 +693,7 @@ exec_command(const char *cmd,
693693
char *opt;
694694

695695
opt = scan_option(&string, OT_NORMAL, NULL, false);
696-
newval = xstrdup(opt ? opt : "");
696+
newval = pg_strdup(opt ? opt : "");
697697
free(opt);
698698

699699
while ((opt = scan_option(&string, OT_NORMAL, NULL, false)))
@@ -1057,7 +1057,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
10571057
}
10581058
else
10591059
{
1060-
return_val = xstrdup("");
1060+
return_val = pg_strdup("");
10611061
termPQExpBuffer(&output);
10621062
}
10631063

@@ -1081,7 +1081,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
10811081
save_char = options_string[pos + token_end + 1];
10821082
options_string[pos + token_end + 1] = '\0';
10831083
value = GetVariable(pset.vars, options_string + pos + 1);
1084-
return_val = xstrdup(value ? value : "");
1084+
return_val = pg_strdup(value ? value : "");
10851085
options_string[pos + token_end + 1] = save_char;
10861086
*string = &options_string[pos + token_end + 1];
10871087
/* XXX should we set *quote to ':' here? */
@@ -1096,7 +1096,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
10961096
if (type == OT_FILEPIPE)
10971097
{
10981098
*string += strlen(*string);
1099-
return xstrdup(options_string + pos);
1099+
return pg_strdup(options_string + pos);
11001100
}
11011101
/* fallthrough for other option types */
11021102

@@ -1156,7 +1156,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
11561156
/* Copy the option */
11571157
token_len = cp - &options_string[pos];
11581158

1159-
return_val = xmalloc(token_len + 1);
1159+
return_val = pg_malloc(token_len + 1);
11601160
memcpy(return_val, &options_string[pos], token_len);
11611161
return_val[token_len] = '\0';
11621162

@@ -1245,7 +1245,7 @@ unescape(const unsigned char *source, size_t len)
12451245

12461246
length = Min(len, strlen(source)) + 1;
12471247

1248-
tmp = destination = xmalloc(length);
1248+
tmp = destination = pg_malloc(length);
12491249

12501250
for (p = source; p - source < (int) len && *p; p += PQmblen(p, pset.encoding))
12511251
{
@@ -1526,7 +1526,7 @@ editFile(const char *fname)
15261526
if (!editorName)
15271527
editorName = DEFAULT_EDITOR;
15281528

1529-
sys = xmalloc(strlen(editorName) + strlen(fname) + 10 + 1);
1529+
sys = pg_malloc(strlen(editorName) + strlen(fname) + 10 + 1);
15301530
sprintf(sys,
15311531
#ifndef WIN32
15321532
"exec "
@@ -1802,7 +1802,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
18021802
if (value)
18031803
{
18041804
free(popt->nullPrint);
1805-
popt->nullPrint = xstrdup(value);
1805+
popt->nullPrint = pg_strdup(value);
18061806
}
18071807
if (!quiet)
18081808
printf(gettext("Null display is \"%s\".\n"), popt->nullPrint ? popt->nullPrint : "");
@@ -1814,7 +1814,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
18141814
if (value)
18151815
{
18161816
free(popt->topt.fieldSep);
1817-
popt->topt.fieldSep = xstrdup(value);
1817+
popt->topt.fieldSep = pg_strdup(value);
18181818
}
18191819
if (!quiet)
18201820
printf(gettext("Field separator is \"%s\".\n"), popt->topt.fieldSep);
@@ -1826,7 +1826,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
18261826
if (value)
18271827
{
18281828
free(popt->topt.recordSep);
1829-
popt->topt.recordSep = xstrdup(value);
1829+
popt->topt.recordSep = pg_strdup(value);
18301830
}
18311831
if (!quiet)
18321832
{
@@ -1857,7 +1857,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
18571857
if (!value)
18581858
popt->title = NULL;
18591859
else
1860-
popt->title = xstrdup(value);
1860+
popt->title = pg_strdup(value);
18611861

18621862
if (!quiet)
18631863
{
@@ -1875,7 +1875,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
18751875
if (!value)
18761876
popt->topt.tableAttr = NULL;
18771877
else
1878-
popt->topt.tableAttr = xstrdup(value);
1878+
popt->topt.tableAttr = pg_strdup(value);
18791879

18801880
if (!quiet)
18811881
{
@@ -1946,7 +1946,7 @@ do_shell(const char *command)
19461946
if (shellName == NULL)
19471947
shellName = DEFAULT_SHELL;
19481948

1949-
sys = xmalloc(strlen(shellName) + 16);
1949+
sys = pg_malloc(strlen(shellName) + 16);
19501950
sprintf(sys,
19511951
#ifndef WIN32
19521952
"exec "

src/bin/psql/common.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.81 2004/01/24 19:38:49 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.82 2004/01/25 03:07:22 neilc Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -70,7 +70,7 @@ static bool is_transact_command(const char *query);
7070
* "Safe" wrapper around strdup()
7171
*/
7272
char *
73-
xstrdup(const char *string)
73+
pg_strdup(const char *string)
7474
{
7575
char *tmp;
7676

@@ -90,7 +90,7 @@ xstrdup(const char *string)
9090
}
9191

9292
void *
93-
xmalloc(size_t size)
93+
pg_malloc(size_t size)
9494
{
9595
void *tmp;
9696

@@ -104,17 +104,17 @@ xmalloc(size_t size)
104104
}
105105

106106
void *
107-
xmalloc_zero(size_t size)
107+
pg_malloc_zero(size_t size)
108108
{
109109
void *tmp;
110110

111-
tmp = xmalloc(size);
111+
tmp = pg_malloc(size);
112112
memset(tmp, 0, size);
113113
return tmp;
114114
}
115115

116116
void *
117-
xcalloc(size_t nmemb, size_t size)
117+
pg_calloc(size_t nmemb, size_t size)
118118
{
119119
void *tmp;
120120

@@ -127,7 +127,6 @@ xcalloc(size_t nmemb, size_t size)
127127
return tmp;
128128
}
129129

130-
131130
/*
132131
* setQFout
133132
* -- handler for -o command line option and \o command
@@ -891,7 +890,7 @@ expand_tilde(char **filename)
891890
{
892891
char *newfn;
893892

894-
newfn = xmalloc(strlen(home) + strlen(p) + 1);
893+
newfn = pg_malloc(strlen(home) + strlen(p) + 1);
895894
strcpy(newfn, home);
896895
strcat(newfn, p);
897896

src/bin/psql/common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.33 2004/01/24 19:38:49 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.34 2004/01/25 03:07:22 neilc Exp $
77
*/
88
#ifndef COMMON_H
99
#define COMMON_H
@@ -25,10 +25,10 @@
2525
* out-of-memory condition occurs, these functions will bail out
2626
* safely; therefore, their return value is guaranteed to be non-NULL.
2727
*/
28-
extern char *xstrdup(const char *string);
29-
extern void *xmalloc(size_t size);
30-
extern void *xmalloc_zero(size_t size);
31-
extern void *xcalloc(size_t nmemb, size_t size);
28+
extern char *pg_strdup(const char *string);
29+
extern void *pg_malloc(size_t size);
30+
extern void *pg_malloc_zero(size_t size);
31+
extern void *pg_calloc(size_t nmemb, size_t size);
3232

3333
extern bool setQFout(const char *fname);
3434

src/bin/psql/copy.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.38 2004/01/24 19:38:49 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.39 2004/01/25 03:07:22 neilc Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "copy.h"
@@ -83,7 +83,7 @@ xstrcat(char **var, const char *more)
8383
{
8484
char *newvar;
8585

86-
newvar = xmalloc(strlen(*var) + strlen(more) + 1);
86+
newvar = pg_malloc(strlen(*var) + strlen(more) + 1);
8787
strcpy(newvar, *var);
8888
strcat(newvar, more);
8989
free(*var);
@@ -100,14 +100,14 @@ parse_slash_copy(const char *args)
100100
const char *whitespace = " \t\n\r";
101101

102102
if (args)
103-
line = xstrdup(args);
103+
line = pg_strdup(args);
104104
else
105105
{
106106
psql_error("\\copy: arguments required\n");
107107
return NULL;
108108
}
109109

110-
result = xcalloc(1, sizeof(struct copy_options));
110+
result = pg_calloc(1, sizeof(struct copy_options));
111111

112112
token = strtokx(line, whitespace, ".,()", "\"",
113113
0, false, pset.encoding);
@@ -126,7 +126,7 @@ parse_slash_copy(const char *args)
126126
}
127127
#endif
128128

129-
result->table = xstrdup(token);
129+
result->table = pg_strdup(token);
130130

131131
token = strtokx(NULL, whitespace, ".,()", "\"",
132132
0, false, pset.encoding);
@@ -156,7 +156,7 @@ parse_slash_copy(const char *args)
156156
if (token[0] == '(')
157157
{
158158
/* handle parenthesized column list */
159-
result->column_list = xstrdup(token);
159+
result->column_list = pg_strdup(token);
160160
for (;;)
161161
{
162162
token = strtokx(NULL, whitespace, ".,()", "\"",
@@ -227,7 +227,7 @@ parse_slash_copy(const char *args)
227227
else
228228
{
229229
result->in_dash = false;
230-
result->file = xstrdup(token);
230+
result->file = pg_strdup(token);
231231
expand_tilde(&result->file);
232232
}
233233

@@ -247,7 +247,7 @@ parse_slash_copy(const char *args)
247247
'\\', false, pset.encoding);
248248
if (!token)
249249
goto error;
250-
result->delim = xstrdup(token);
250+
result->delim = pg_strdup(token);
251251
token = strtokx(NULL, whitespace, NULL, NULL,
252252
0, false, pset.encoding);
253253
}
@@ -267,7 +267,7 @@ parse_slash_copy(const char *args)
267267
token = strtokx(NULL, whitespace, NULL, "'",
268268
'\\', false, pset.encoding);
269269
if (token)
270-
result->delim = xstrdup(token);
270+
result->delim = pg_strdup(token);
271271
else
272272
goto error;
273273
}
@@ -279,7 +279,7 @@ parse_slash_copy(const char *args)
279279
token = strtokx(NULL, whitespace, NULL, "'",
280280
'\\', false, pset.encoding);
281281
if (token)
282-
result->null = xstrdup(token);
282+
result->null = pg_strdup(token);
283283
else
284284
goto error;
285285
}

0 commit comments

Comments
 (0)