mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
DBI Changes
fixed possible memory leak
This commit is contained in:
parent
2a1e246658
commit
c1291e7504
@ -70,6 +70,16 @@ PGconn* make_connection(const char *h, const char *u, const char *ps, const char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *c_info = make_connstring(h, u, ps, n);
|
char *c_info = make_connstring(h, u, ps, n);
|
||||||
|
/* now search for a free one */
|
||||||
|
p = cns;
|
||||||
|
while (p) {
|
||||||
|
if (p->free) {
|
||||||
|
p->set(h, u, ps, n, p->ii());
|
||||||
|
return p->v.cn;
|
||||||
|
} else {
|
||||||
|
p = p->link();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (cns == NULL) {
|
if (cns == NULL) {
|
||||||
cns = new pgs;
|
cns = new pgs;
|
||||||
PGconn *cn = PQconnectdb(c_info);
|
PGconn *cn = PQconnectdb(c_info);
|
||||||
@ -190,12 +200,12 @@ static cell AMX_NATIVE_CALL pgsql_close(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO pgsql_exports[] = {
|
AMX_NATIVE_INFO pgsql_exports[] = {
|
||||||
{"pgsql_connect", pgsql_connect},
|
{"dbi_connect", pgsql_connect},
|
||||||
{"pgsql_error", pgsql_error},
|
{"dbi_error", pgsql_error},
|
||||||
{"pgsql_query", pgsql_query},
|
{"dbi_query", pgsql_query},
|
||||||
{"pgsql_nextrow", pgsql_nextrow},
|
{"dbi_nextrow", pgsql_nextrow},
|
||||||
{"pgsql_close", pgsql_close},
|
{"dbi_close", pgsql_close},
|
||||||
{"pgsql_getfield", pgsql_getfield},
|
{"dbi_getfield", pgsql_getfield},
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -76,6 +76,7 @@ public:
|
|||||||
v.row = 0;
|
v.row = 0;
|
||||||
next = NULL;
|
next = NULL;
|
||||||
id = i;
|
id = i;
|
||||||
|
free = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgs* link()
|
pgs* link()
|
||||||
@ -111,6 +112,10 @@ public:
|
|||||||
destroy(v.user);
|
destroy(v.user);
|
||||||
destroy(v.pass);
|
destroy(v.pass);
|
||||||
destroy(v.name);
|
destroy(v.name);
|
||||||
|
destroy(v.cn);
|
||||||
|
destroy(v.res);
|
||||||
|
v.row = 0;
|
||||||
|
free = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pgsql {
|
struct pgsql {
|
||||||
@ -130,5 +135,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
pgs *next;
|
pgs *next;
|
||||||
|
bool free;
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user