diff options
Diffstat (limited to 'src/bin/psql/input.c')
-rw-r--r-- | src/bin/psql/input.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index 90c2c92993d..6a2afa35bd3 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.32 2003/11/29 19:52:06 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.33 2004/01/24 19:38:49 neilc Exp $ */ #include "postgres_fe.h" #include "input.h" @@ -83,7 +83,7 @@ gets_basic(const char prompt[]) * gets_interactive() * * Gets a line of interactive input, using readline of desired. - * The result is malloced. + * The result is malloc'ed. */ char * gets_interactive(const char *prompt) @@ -113,7 +113,7 @@ gets_interactive(const char *prompt) else { free(prev_hist); - prev_hist = strdup(s); + prev_hist = xstrdup(s); add_history(s); } } @@ -183,15 +183,13 @@ initializeInput(int flags) home = getenv("HOME"); if (home) { - char *psql_history = (char *) malloc(strlen(home) + 1 + - strlen(PSQLHISTORY) + 1); - - if (psql_history) - { - sprintf(psql_history, "%s/%s", home, PSQLHISTORY); - read_history(psql_history); - free(psql_history); - } + char *psql_history; + + psql_history = xmalloc(strlen(home) + 1 + + strlen(PSQLHISTORY) + 1); + sprintf(psql_history, "%s/%s", home, PSQLHISTORY); + read_history(psql_history); + free(psql_history); } } #endif @@ -234,26 +232,24 @@ finishInput(int exitstatus, void *arg) if (useHistory) { char *home; - char *psql_history; home = getenv("HOME"); if (home) { - psql_history = (char *) malloc(strlen(home) + 1 + - strlen(PSQLHISTORY) + 1); - if (psql_history) - { - int hist_size; + char *psql_history; + int hist_size; + + psql_history = xmalloc(strlen(home) + 1 + + strlen(PSQLHISTORY) + 1); - hist_size = GetVariableNum(pset.vars, "HISTSIZE", -1, -1, true); + hist_size = GetVariableNum(pset.vars, "HISTSIZE", -1, -1, true); - if (hist_size >= 0) - stifle_history(hist_size); + if (hist_size >= 0) + stifle_history(hist_size); - sprintf(psql_history, "%s/%s", home, PSQLHISTORY); - write_history(psql_history); - free(psql_history); - } + sprintf(psql_history, "%s/%s", home, PSQLHISTORY); + write_history(psql_history); + free(psql_history); } } #endif |