aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/variables.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/variables.c')
-rw-r--r--src/bin/psql/variables.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c
index 21dc8aecb68..31c5510ad83 100644
--- a/src/bin/psql/variables.c
+++ b/src/bin/psql/variables.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.15 2003/12/01 22:14:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.16 2004/01/24 19:38:49 neilc Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -14,19 +14,9 @@ CreateVariableSpace(void)
{
struct _variable *ptr;
- ptr = calloc(1, sizeof *ptr);
- if (!ptr)
- return NULL;
-
- ptr->name = strdup("@");
- ptr->value = strdup("");
- if (!ptr->name || !ptr->value)
- {
- free(ptr->name);
- free(ptr->value);
- free(ptr);
- return NULL;
- }
+ ptr = xcalloc(1, sizeof *ptr);
+ ptr->name = xstrdup("@");
+ ptr->value = xstrdup("");
return ptr;
}
@@ -162,19 +152,15 @@ SetVariable(VariableSpace space, const char *name, const char *value)
if (strcmp(current->name, name) == 0)
{
free(current->value);
- current->value = strdup(value);
- return current->value ? true : false;
+ current->value = xstrdup(value);
+ return true;
}
}
- previous->next = calloc(1, sizeof *(previous->next));
- if (!previous->next)
- return false;
- previous->next->name = strdup(name);
- if (!previous->next->name)
- return false;
- previous->next->value = strdup(value);
- return previous->next->value ? true : false;
+ previous->next = xcalloc(1, sizeof *(previous->next));
+ previous->next->name = xstrdup(name);
+ previous->next->value = xstrdup(value);
+ return true;
}
bool