Commit e10bb051 authored by Neil Conway's avatar Neil Conway

More fallout from the recent psql patch: rename xmalloc and friends to

pg_malloc, to avoid linker failures on same platforms.
parent afe7b7b6
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.110 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.111 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "command.h"
......@@ -97,7 +97,7 @@ HandleSlashCmds(const char *line,
* backslash command ended */
psql_assert(line);
my_line = xstrdup(line);
my_line = pg_strdup(line);
/*
* Find the first whitespace. line[blank_loc] will now be the
......@@ -199,7 +199,7 @@ exec_command(const char *cmd,
* end.
*/
if (options_string)
string = string_cpy = xstrdup(options_string);
string = string_cpy = pg_strdup(options_string);
else
string = string_cpy = NULL;
......@@ -497,7 +497,7 @@ exec_command(const char *cmd,
else
{
expand_tilde(&fname);
pset.gfname = xstrdup(fname);
pset.gfname = pg_strdup(fname);
}
free(fname);
status = CMD_SEND;
......@@ -693,7 +693,7 @@ exec_command(const char *cmd,
char *opt;
opt = scan_option(&string, OT_NORMAL, NULL, false);
newval = xstrdup(opt ? opt : "");
newval = pg_strdup(opt ? opt : "");
free(opt);
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)
}
else
{
return_val = xstrdup("");
return_val = pg_strdup("");
termPQExpBuffer(&output);
}
......@@ -1081,7 +1081,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
save_char = options_string[pos + token_end + 1];
options_string[pos + token_end + 1] = '\0';
value = GetVariable(pset.vars, options_string + pos + 1);
return_val = xstrdup(value ? value : "");
return_val = pg_strdup(value ? value : "");
options_string[pos + token_end + 1] = save_char;
*string = &options_string[pos + token_end + 1];
/* XXX should we set *quote to ':' here? */
......@@ -1096,7 +1096,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
if (type == OT_FILEPIPE)
{
*string += strlen(*string);
return xstrdup(options_string + pos);
return pg_strdup(options_string + pos);
}
/* fallthrough for other option types */
......@@ -1156,7 +1156,7 @@ scan_option(char **string, enum option_type type, char *quote, bool semicolon)
/* Copy the option */
token_len = cp - &options_string[pos];
return_val = xmalloc(token_len + 1);
return_val = pg_malloc(token_len + 1);
memcpy(return_val, &options_string[pos], token_len);
return_val[token_len] = '\0';
......@@ -1245,7 +1245,7 @@ unescape(const unsigned char *source, size_t len)
length = Min(len, strlen(source)) + 1;
tmp = destination = xmalloc(length);
tmp = destination = pg_malloc(length);
for (p = source; p - source < (int) len && *p; p += PQmblen(p, pset.encoding))
{
......@@ -1526,7 +1526,7 @@ editFile(const char *fname)
if (!editorName)
editorName = DEFAULT_EDITOR;
sys = xmalloc(strlen(editorName) + strlen(fname) + 10 + 1);
sys = pg_malloc(strlen(editorName) + strlen(fname) + 10 + 1);
sprintf(sys,
#ifndef WIN32
"exec "
......@@ -1802,7 +1802,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (value)
{
free(popt->nullPrint);
popt->nullPrint = xstrdup(value);
popt->nullPrint = pg_strdup(value);
}
if (!quiet)
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)
if (value)
{
free(popt->topt.fieldSep);
popt->topt.fieldSep = xstrdup(value);
popt->topt.fieldSep = pg_strdup(value);
}
if (!quiet)
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)
if (value)
{
free(popt->topt.recordSep);
popt->topt.recordSep = xstrdup(value);
popt->topt.recordSep = pg_strdup(value);
}
if (!quiet)
{
......@@ -1857,7 +1857,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!value)
popt->title = NULL;
else
popt->title = xstrdup(value);
popt->title = pg_strdup(value);
if (!quiet)
{
......@@ -1875,7 +1875,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!value)
popt->topt.tableAttr = NULL;
else
popt->topt.tableAttr = xstrdup(value);
popt->topt.tableAttr = pg_strdup(value);
if (!quiet)
{
......@@ -1946,7 +1946,7 @@ do_shell(const char *command)
if (shellName == NULL)
shellName = DEFAULT_SHELL;
sys = xmalloc(strlen(shellName) + 16);
sys = pg_malloc(strlen(shellName) + 16);
sprintf(sys,
#ifndef WIN32
"exec "
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.81 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.82 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "common.h"
......@@ -70,7 +70,7 @@ static bool is_transact_command(const char *query);
* "Safe" wrapper around strdup()
*/
char *
xstrdup(const char *string)
pg_strdup(const char *string)
{
char *tmp;
......@@ -90,7 +90,7 @@ xstrdup(const char *string)
}
void *
xmalloc(size_t size)
pg_malloc(size_t size)
{
void *tmp;
......@@ -104,17 +104,17 @@ xmalloc(size_t size)
}
void *
xmalloc_zero(size_t size)
pg_malloc_zero(size_t size)
{
void *tmp;
tmp = xmalloc(size);
tmp = pg_malloc(size);
memset(tmp, 0, size);
return tmp;
}
void *
xcalloc(size_t nmemb, size_t size)
pg_calloc(size_t nmemb, size_t size)
{
void *tmp;
......@@ -127,7 +127,6 @@ xcalloc(size_t nmemb, size_t size)
return tmp;
}
/*
* setQFout
* -- handler for -o command line option and \o command
......@@ -891,7 +890,7 @@ expand_tilde(char **filename)
{
char *newfn;
newfn = xmalloc(strlen(home) + strlen(p) + 1);
newfn = pg_malloc(strlen(home) + strlen(p) + 1);
strcpy(newfn, home);
strcat(newfn, p);
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.33 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.34 2004/01/25 03:07:22 neilc Exp $
*/
#ifndef COMMON_H
#define COMMON_H
......@@ -25,10 +25,10 @@
* out-of-memory condition occurs, these functions will bail out
* safely; therefore, their return value is guaranteed to be non-NULL.
*/
extern char *xstrdup(const char *string);
extern void *xmalloc(size_t size);
extern void *xmalloc_zero(size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *pg_strdup(const char *string);
extern void *pg_malloc(size_t size);
extern void *pg_malloc_zero(size_t size);
extern void *pg_calloc(size_t nmemb, size_t size);
extern bool setQFout(const char *fname);
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.38 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.39 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
......@@ -83,7 +83,7 @@ xstrcat(char **var, const char *more)
{
char *newvar;
newvar = xmalloc(strlen(*var) + strlen(more) + 1);
newvar = pg_malloc(strlen(*var) + strlen(more) + 1);
strcpy(newvar, *var);
strcat(newvar, more);
free(*var);
......@@ -100,14 +100,14 @@ parse_slash_copy(const char *args)
const char *whitespace = " \t\n\r";
if (args)
line = xstrdup(args);
line = pg_strdup(args);
else
{
psql_error("\\copy: arguments required\n");
return NULL;
}
result = xcalloc(1, sizeof(struct copy_options));
result = pg_calloc(1, sizeof(struct copy_options));
token = strtokx(line, whitespace, ".,()", "\"",
0, false, pset.encoding);
......@@ -126,7 +126,7 @@ parse_slash_copy(const char *args)
}
#endif
result->table = xstrdup(token);
result->table = pg_strdup(token);
token = strtokx(NULL, whitespace, ".,()", "\"",
0, false, pset.encoding);
......@@ -156,7 +156,7 @@ parse_slash_copy(const char *args)
if (token[0] == '(')
{
/* handle parenthesized column list */
result->column_list = xstrdup(token);
result->column_list = pg_strdup(token);
for (;;)
{
token = strtokx(NULL, whitespace, ".,()", "\"",
......@@ -227,7 +227,7 @@ parse_slash_copy(const char *args)
else
{
result->in_dash = false;
result->file = xstrdup(token);
result->file = pg_strdup(token);
expand_tilde(&result->file);
}
......@@ -247,7 +247,7 @@ parse_slash_copy(const char *args)
'\\', false, pset.encoding);
if (!token)
goto error;
result->delim = xstrdup(token);
result->delim = pg_strdup(token);
token = strtokx(NULL, whitespace, NULL, NULL,
0, false, pset.encoding);
}
......@@ -267,7 +267,7 @@ parse_slash_copy(const char *args)
token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding);
if (token)
result->delim = xstrdup(token);
result->delim = pg_strdup(token);
else
goto error;
}
......@@ -279,7 +279,7 @@ parse_slash_copy(const char *args)
token = strtokx(NULL, whitespace, NULL, "'",
'\\', false, pset.encoding);
if (token)
result->null = xstrdup(token);
result->null = pg_strdup(token);
else
goto error;
}
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.93 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.94 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
......@@ -39,17 +39,6 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern,
const char *schemavar, const char *namevar,
const char *altnamevar, const char *visibilityrule);
static void *
xmalloczero(size_t size)
{
void *tmp;
tmp = xmalloc(size);
memset(tmp, 0, size);
return tmp;
}
/*----------------
* Handlers for various slash commands displaying some sort of list
* of things in the database.
......@@ -737,14 +726,14 @@ describeOneTableDetails(const char *schemaname,
goto error_return;
if (PQntuples(result) > 0)
view_def = xstrdup(PQgetvalue(result, 0, 0));
view_def = pg_strdup(PQgetvalue(result, 0, 0));
PQclear(result);
}
/* Generate table cells to be printed */
/* note: initialize all cells[] to NULL in case of error exit */
cells = xmalloczero((numrows * cols + 1) * sizeof(*cells));
cells = pg_malloc_zero((numrows * cols + 1) * sizeof(*cells));
for (i = 0; i < numrows; i++)
{
......@@ -782,9 +771,9 @@ describeOneTableDetails(const char *schemaname,
}
#ifdef WIN32
cells[i * cols + 2] = xstrdup(mbvalidate(tmpbuf.data, myopt.encoding));
cells[i * cols + 2] = pg_strdup(mbvalidate(tmpbuf.data, myopt.encoding));
#else
cells[i * cols + 2] = xstrdup(tmpbuf.data);
cells[i * cols + 2] = pg_strdup(tmpbuf.data);
#endif
}
......@@ -879,8 +868,8 @@ describeOneTableDetails(const char *schemaname,
if (strlen(indpred))
appendPQExpBuffer(&tmpbuf, _(", predicate (%s)"), indpred);
footers = xmalloczero(2 * sizeof(*footers));
footers[0] = xstrdup(tmpbuf.data);
footers = pg_malloc_zero(2 * sizeof(*footers));
footers[0] = pg_strdup(tmpbuf.data);
footers[1] = NULL;
}
......@@ -908,8 +897,8 @@ describeOneTableDetails(const char *schemaname,
}
/* Footer information about a view */
footers = xmalloczero((rule_count + 3) * sizeof(*footers));
footers[count_footers] = xmalloc(64 + strlen(view_def));
footers = pg_malloc_zero((rule_count + 3) * sizeof(*footers));
footers[count_footers] = pg_malloc(64 + strlen(view_def));
snprintf(footers[count_footers], 64 + strlen(view_def),
_("View definition:\n%s"), view_def);
count_footers++;
......@@ -918,7 +907,7 @@ describeOneTableDetails(const char *schemaname,
if (rule_count > 0)
{
printfPQExpBuffer(&buf, _("Rules:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < rule_count; i++)
{
const char *ruledef;
......@@ -929,7 +918,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf, " %s", ruledef);
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
PQclear(result);
}
......@@ -1066,14 +1055,14 @@ describeOneTableDetails(const char *schemaname,
else
inherits_count = PQntuples(result6);
footers = xmalloczero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 6)
* sizeof(*footers));
footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 6)
* sizeof(*footers));
/* print indexes */
if (index_count > 0)
{
printfPQExpBuffer(&buf, _("Indexes:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < index_count; i++)
{
const char *indexdef;
......@@ -1099,7 +1088,7 @@ describeOneTableDetails(const char *schemaname,
appendPQExpBuffer(&buf, " %s", indexdef);
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
}
......@@ -1107,14 +1096,14 @@ describeOneTableDetails(const char *schemaname,
if (check_count > 0)
{
printfPQExpBuffer(&buf, _("Check constraints:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < check_count; i++)
{
printfPQExpBuffer(&buf, _(" \"%s\" %s"),
PQgetvalue(result2, i, 1),
PQgetvalue(result2, i, 0));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
}
......@@ -1122,14 +1111,14 @@ describeOneTableDetails(const char *schemaname,
if (foreignkey_count > 0)
{
printfPQExpBuffer(&buf, _("Foreign-key constraints:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < foreignkey_count; i++)
{
printfPQExpBuffer(&buf, _(" \"%s\" %s"),
PQgetvalue(result5, i, 0),
PQgetvalue(result5, i, 1));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
}
......@@ -1137,7 +1126,7 @@ describeOneTableDetails(const char *schemaname,
if (rule_count > 0)
{
printfPQExpBuffer(&buf, _("Rules:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < rule_count; i++)
{
const char *ruledef;
......@@ -1148,7 +1137,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf, " %s", ruledef);
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
}
......@@ -1156,7 +1145,7 @@ describeOneTableDetails(const char *schemaname,
if (trigger_count > 0)
{
printfPQExpBuffer(&buf, _("Triggers:"));
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
for (i = 0; i < trigger_count; i++)
{
const char *tgdef;
......@@ -1170,7 +1159,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf, " %s", tgdef);
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
}
......@@ -1186,7 +1175,7 @@ describeOneTableDetails(const char *schemaname,
if (i < inherits_count - 1)
appendPQExpBuffer(&buf, ",");
footers[count_footers++] = xstrdup(buf.data);
footers[count_footers++] = pg_strdup(buf.data);
}
/* end of list marker */
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.33 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.34 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "input.h"
......@@ -113,7 +113,7 @@ gets_interactive(const char *prompt)
else
{
free(prev_hist);
prev_hist = xstrdup(s);
prev_hist = pg_strdup(s);
add_history(s);
}
}
......@@ -185,8 +185,8 @@ initializeInput(int flags)
{
char *psql_history;
psql_history = xmalloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
psql_history = pg_malloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
sprintf(psql_history, "%s/%s", home, PSQLHISTORY);
read_history(psql_history);
free(psql_history);
......@@ -239,8 +239,8 @@ finishInput(int exitstatus, void *arg)
char *psql_history;
int hist_size;
psql_history = xmalloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
psql_history = pg_malloc(strlen(home) + 1 +
strlen(PSQLHISTORY) + 1);
hist_size = GetVariableNum(pset.vars, "HISTSIZE", -1, -1, true);
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.60 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.61 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
......@@ -144,7 +144,7 @@ MainLoop(FILE *source)
* just returned from editing the line? then just copy to the
* input buffer
*/
line = xstrdup(query_buf->data);
line = pg_strdup(query_buf->data);
resetPQExpBuffer(query_buf);
/* reset parsing state since we are rescanning whole line */
in_xcomment = 0;
......@@ -332,7 +332,7 @@ MainLoop(FILE *source)
/* It is a variable, perform substitution */
out_length = strlen(value);
new = xmalloc(len + out_length - in_length + 1);
new = pg_malloc(len + out_length - in_length + 1);
sprintf(new, "%.*s%s%s", i, line, value,
&line[i + thislen + in_length]);
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.33 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.34 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "prompt.h"
......@@ -248,7 +248,7 @@ get_prompt(promptStatus_t status)
case '`':
{
FILE *fd = NULL;
char *file = xstrdup(p + 1);
char *file = pg_strdup(p + 1);
int cmdend;
cmdend = strcspn(file, "`");
......@@ -274,7 +274,7 @@ get_prompt(promptStatus_t status)
const char *val;
int nameend;
name = xstrdup(p + 1);
name = pg_strdup(p + 1);
nameend = strcspn(name, ":");
name[nameend] = '\0';
val = GetVariable(pset.vars, name);
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.82 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.83 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
......@@ -156,9 +156,9 @@ main(int argc, char *argv[])
parse_psql_options(argc, argv, &options);
if (!pset.popt.topt.fieldSep)
pset.popt.topt.fieldSep = xstrdup(DEFAULT_FIELD_SEP);
pset.popt.topt.fieldSep = pg_strdup(DEFAULT_FIELD_SEP);
if (!pset.popt.topt.recordSep)
pset.popt.topt.recordSep = xstrdup(DEFAULT_RECORD_SEP);
pset.popt.topt.recordSep = pg_strdup(DEFAULT_RECORD_SEP);
if (options.username)
{
......@@ -170,7 +170,7 @@ main(int argc, char *argv[])
if (strcmp(options.username, "\001") == 0)
username = simple_prompt("User name: ", 100, true);
else
username = xstrdup(options.username);
username = pg_strdup(options.username);
}
if (pset.getPassword)
......@@ -387,7 +387,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
options->action_string = optarg;
break;
case 'F':
pset.popt.topt.fieldSep = xstrdup(optarg);
pset.popt.topt.fieldSep = pg_strdup(optarg);
break;
case 'h':
options->host = optarg;
......@@ -413,7 +413,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
char *equal_loc;
bool result;
value = xstrdup(optarg);
value = pg_strdup(optarg);
equal_loc = strchr(value, '=');
if (!equal_loc)
result = do_pset(value, NULL, &pset.popt, true);
......@@ -436,7 +436,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
SetVariableBool(pset.vars, "QUIET");
break;
case 'R':
pset.popt.topt.recordSep = xstrdup(optarg);
pset.popt.topt.recordSep = pg_strdup(optarg);
break;
case 's':
SetVariableBool(pset.vars, "SINGLESTEP");
......@@ -448,7 +448,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
pset.popt.topt.tuples_only = true;
break;
case 'T':
pset.popt.topt.tableAttr = xstrdup(optarg);
pset.popt.topt.tableAttr = pg_strdup(optarg);
break;
case 'u':
pset.getPassword = true;
......@@ -465,7 +465,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
char *value;
char *equal_loc;
value = xstrdup(optarg);
value = pg_strdup(optarg);
equal_loc = strchr(value, '=');
if (!equal_loc)
{
......@@ -567,8 +567,8 @@ process_psqlrc(void)
if (home)
{
psqlrc = xmalloc(strlen(home) + 1 + strlen(PSQLRC) + 1 +
strlen(PG_VERSION) + 1);
psqlrc = pg_malloc(strlen(home) + 1 + strlen(PSQLRC) + 1 +
strlen(PG_VERSION) + 1);
sprintf(psqlrc, "%s/%s-%s", home, PSQLRC, PG_VERSION);
if (access(psqlrc, R_OK) == 0)
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.37 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.38 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
......@@ -77,7 +77,7 @@ strtokx(const char *s,
* tokens. 2X the space is a gross overestimate, but it's
* unlikely that this code will be used on huge strings anyway.
*/
storage = xmalloc(2 * strlen(s) + 1);
storage = pg_malloc(2 * strlen(s) + 1);
strcpy(storage, s);
string = storage;
}
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.99 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.100 2004/01/25 03:07:22 neilc Exp $
*/
/*----------------------------------------------------------------------
......@@ -1417,7 +1417,7 @@ create_command_generator(const char *text, int state)
/* find something that matches */
while ((name = words_after_create[list_index++].name))
if (strncasecmp(name, text, string_length) == 0)
return xstrdup(name);
return pg_strdup(name);
/* if nothing matches, return NULL */
return NULL;
......@@ -1485,7 +1485,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
/* Set up suitably-escaped copies of textual inputs */
if (text)
{
e_text = xmalloc(strlen(text) * 2 + 1);
e_text = pg_malloc(strlen(text) * 2 + 1);
PQescapeString(e_text, text, strlen(text));
}
else
......@@ -1496,7 +1496,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
size_t charp_len;
charp_len = strlen(completion_info_charp);
e_info_charp = xmalloc(charp_len * 2 + 1);
e_info_charp = pg_malloc(charp_len * 2 + 1);
PQescapeString(e_info_charp, completion_info_charp,
charp_len);
}
......@@ -1618,7 +1618,7 @@ _complete_from_query(int is_schema_query, const char *text, int state)
while (list_index < PQntuples(result) &&
(item = PQgetvalue(result, list_index++, 0)))
if (strncasecmp(text, item, string_length) == 0)
return xstrdup(item);
return pg_strdup(item);
}
/* If nothing matches, free the db structure and return null */
......@@ -1659,12 +1659,12 @@ complete_from_list(const char *text, int state)
if (casesensitive && strncmp(text, item, string_length) == 0)
{
matches++;
return xstrdup(item);
return pg_strdup(item);
}
/* Second pass is case insensitive, don't bother counting matches */
if (!casesensitive && strncasecmp(text, item, string_length) == 0)
return xstrdup(item);
return pg_strdup(item);
}
/*
......@@ -1698,7 +1698,7 @@ complete_from_const(const char *text, int state)
psql_assert(completion_charp);
if (state == 0)
return xstrdup(completion_charp);
return pg_strdup(completion_charp);
else
return NULL;
}
......@@ -1788,7 +1788,7 @@ previous_word(int point, int skip)
}
/* make a copy */
s = xmalloc(end - start + 2);
s = pg_malloc(end - start + 2);
strncpy(s, &rl_line_buffer[start], end - start + 1);
s[end - start + 1] = '\0';
......@@ -1814,7 +1814,7 @@ quote_file_name(char *text, int match_type, char *quote_pointer)
(void) quote_pointer; /* not used */
length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2);
s = xmalloc(length);
s = pg_malloc(length);
s[0] = '\'';
strcpy(s + 1, text);
if (match_type == SINGLE_MATCH)
......@@ -1832,10 +1832,10 @@ dequote_file_name(char *text, char quote_char)
size_t length;
if (!quote_char)
return xstrdup(text);
return pg_strdup(text);
length = strlen(text);
s = xmalloc(length - 2 + 1);
s = pg_malloc(length - 2 + 1);
strncpy(s, text +1, length - 2);
s[length] = '\0';
......
......@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.16 2004/01/24 19:38:49 neilc Exp $
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.17 2004/01/25 03:07:22 neilc Exp $
*/
#include "postgres_fe.h"
#include "common.h"
......@@ -14,9 +14,9 @@ CreateVariableSpace(void)
{
struct _variable *ptr;
ptr = xcalloc(1, sizeof *ptr);
ptr->name = xstrdup("@");
ptr->value = xstrdup("");
ptr = pg_calloc(1, sizeof *ptr);
ptr->name = pg_strdup("@");
ptr->value = pg_strdup("");
return ptr;
}
......@@ -152,14 +152,14 @@ SetVariable(VariableSpace space, const char *name, const char *value)
if (strcmp(current->name, name) == 0)
{
free(current->value);
current->value = xstrdup(value);
current->value = pg_strdup(value);
return true;
}
}
previous->next = xcalloc(1, sizeof *(previous->next));
previous->next->name = xstrdup(name);
previous->next->value = xstrdup(value);
previous->next = pg_calloc(1, sizeof *(previous->next));
previous->next->name = pg_strdup(name);
previous->next->value = pg_strdup(value);
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment