1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

- Made several variables "const char *" instead of "char *" as proposed by Qingqing Zhou <zhouqq@cs.toronto.edu>.

- Replaced all strdup() calls by ECPGstrdup().
This commit is contained in:
Michael Meskes
2005-11-30 12:50:37 +00:00
parent c4279b45fd
commit dd13bf167b
5 changed files with 37 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.1 2005/11/30 12:50:37 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@ -265,7 +265,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
struct sqlca_t *sqlca = ECPGget_sqlca();
enum COMPAT_MODE compat = c;
struct connection *this;
char *dbname = name ? strdup(name) : NULL,
char *dbname = name ? ECPGstrdup(name, lineno) : NULL,
*host = NULL,
*tmp,
*port = NULL,
@ -287,7 +287,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (envname)
{
ECPGfree(dbname);
dbname = strdup(envname);
dbname = ECPGstrdup(envname, lineno);
}
}
@ -307,17 +307,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
tmp = strrchr(dbname, ':');
if (tmp != NULL) /* port number given */
{
port = strdup(tmp + 1);
port = ECPGstrdup(tmp + 1, lineno);
*tmp = '\0';
}
tmp = strrchr(dbname, '@');
if (tmp != NULL) /* host name given */
{
host = strdup(tmp + 1);
host = ECPGstrdup(tmp + 1, lineno);
*tmp = '\0';
}
realname = strdup(dbname);
realname = ECPGstrdup(dbname, lineno);
}
else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
{
@ -345,14 +345,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
tmp = strrchr(dbname + offset, '?');
if (tmp != NULL) /* options given */
{
options = strdup(tmp + 1);
options = ECPGstrdup(tmp + 1, lineno);
*tmp = '\0';
}
tmp = last_dir_separator(dbname + offset);
if (tmp != NULL) /* database name given */
{
realname = strdup(tmp + 1);
realname = ECPGstrdup(tmp + 1, lineno);
*tmp = '\0';
}
@ -365,7 +365,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if ((tmp2 = strchr(tmp + 1, ':')) != NULL)
{
*tmp2 = '\0';
host = strdup(tmp + 1);
host = ECPGstrdup(tmp + 1, lineno);
if (strncmp(dbname, "unix:", 5) != 0)
{
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno);
@ -384,7 +384,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
}
else
port = strdup(tmp + 1);
port = ECPGstrdup(tmp + 1, lineno);
}
if (strncmp(dbname, "unix:", 5) == 0)
@ -407,14 +407,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
}
else
host = strdup(dbname + offset);
host = ECPGstrdup(dbname + offset, lineno);
}
else
realname = strdup(dbname);
realname = ECPGstrdup(dbname, lineno);
}
else
realname = strdup(dbname);
realname = ECPGstrdup(dbname, lineno);
}
else
realname = NULL;