Author: jfrederic.clere(a)jboss.com
Date: 2007-10-17 11:08:17 -0400 (Wed, 17 Oct 2007)
New Revision: 1126
Modified:
trunk/sight/native/os/solaris/udpstat.c
Log:
Use pool instead malloc add cleanup.
Modified: trunk/sight/native/os/solaris/udpstat.c
===================================================================
--- trunk/sight/native/os/solaris/udpstat.c 2007-10-17 15:07:37 UTC (rev 1125)
+++ trunk/sight/native/os/solaris/udpstat.c 2007-10-17 15:08:17 UTC (rev 1126)
@@ -32,6 +32,13 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <stropts.h>
#include <sys/tihdr.h>
@@ -119,7 +126,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;
@@ -180,7 +187,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) {
@@ -231,13 +238,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, lpool);
if (e->stat != NULL) {
mib2_udp_t *udp = (mib2_udp_t *)e->stat;
@@ -274,7 +282,7 @@
return 0;
}
e->type = iftype;
- read_mib2(_E, e);
+ read_mib2(_E, e, e->pool);
return P2J(e);
}
@@ -356,5 +364,11 @@
SIGHT_EXPORT_DECLARE(void, UdpStatistics, enum3)(SIGHT_STDARGS,
jlong handle)
{
+ tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
+
UNREFERENCED_STDARGS;
+ if (e) {
+ apr_pool_destroy(e->pool);
+ free(e);
+ }
}
Show replies by date