Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 11:07:37 -0400 (Wed, 17 Oct 2007)
New Revision: 1125
Modified:
trunk/sight/native/os/solaris/tcpstat.c
Log:
Use pool instead malloc add cleanup.
Modified: trunk/sight/native/os/solaris/tcpstat.c
===================================================================
--- trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 14:39:40 UTC (rev 1124)
+++ trunk/sight/native/os/solaris/tcpstat.c 2007-10-17 15:07:37 UTC (rev 1125)
@@ -173,7 +173,7 @@
} tcpconn_enum_t;
/* Read the mib2 object and fill the structures */
-static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e)
+static void read_mib2(JNIEnv *_E, tcpconn_enum_t *e, apr_pool_t* pool)
{
apr_status_t rc = APR_ENOTIMPL;
int sd;
@@ -234,7 +234,7 @@
/* read the data */
databuf.maxlen = req->len;
- databuf.buf = malloc((int)req->len);
+ databuf.buf = apr_palloc(pool, (int)req->len);
databuf.len = 0;
flags = 0;
if (getmsg(sd, (struct strbuf *)0, &databuf, &flags) == -1) {
@@ -285,13 +285,14 @@
jlong pool)
{
tcpconn_enum_t *e;
+ apr_pool_t* lpool = (apr_pool_t *) pool;
if (!(e = (tcpconn_enum_t *)sight_calloc(_E,
sizeof(tcpconn_enum_t),
THROW_FMARK))) {
return;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, pool);
if (e->stat != NULL) {
mib2_tcp_t *tcp = (mib2_tcp_t *)e->stat;
@@ -338,7 +339,7 @@
return 0;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, e->pool);
return P2J(e);
}
@@ -420,5 +421,11 @@
SIGHT_EXPORT_DECLARE(void, TcpStatistics, enum3)(SIGHT_STDARGS,
jlong handle)
{
- /* XXX: Add cleanup */
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
+
+ UNREFERENCED_STDARGS;
+ if (e) {
+ apr_pool_destroy(e->pool);
+ free(e);
+ }
}