<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1250">
<META content="MSHTML 6.00.2900.5659" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><SPAN class=522153808-10112008>Hi
all</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=522153808-10112008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=522153808-10112008>I have written a
module and after running the proxy for quite some time I get out of pkg mem
message.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=522153808-10112008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=522153808-10112008>I attached a piece
of code how I deal with pkg mem. Please let me know if there is something wrong
or forgotten respectively.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=522153808-10112008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=522153808-10112008>Thanks a
lot.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=522153808-10112008>Sebastian</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=522153808-10112008>[snip]</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2>n = body_start.len + pres_uri.len + body_middle.len
+ TUPLE_ID_SIZE + body_end.len;<BR>s = (char *)pkg_malloc(n); /* as pointers are
used must not be freed after last use of any reference */<BR>if(s==NULL)
{<BR><SPAN class=522153808-10112008> </SPAN>LM_ERR("no more
pkg mem for body (%d)\n", n);<BR><SPAN
class=522153808-10112008> </SPAN>return
-1;<BR>}<BR></DIV></FONT>
<DIV><FONT face=Arial size=2>p=s;<BR>memcpy(p, body_start.s,
body_start.len);<BR>p += body_start.len;<BR>memcpy(p, pres_uri.s,
pres_uri.len);<BR>p += pres_uri.len;<BR>memcpy(p, body_middle.s,
body_middle.len);<BR>p += body_middle.len;<BR></FONT><FONT face=Arial
size=2></FONT></DIV>
<DIV><FONT face=Arial size=2>int i;<BR>for(i=0;i<TUPLE_ID_SIZE;i++)
{<BR><SPAN class=522153808-10112008> </SPAN>*(p++) =
tuple[i];<BR>}<BR><BR>memcpy(p, body_end.s, body_end.len);<BR>p +=
body_end.len;<BR>body.s = s;<BR>body.len = (int)(p-s);<BR><BR>if(body.len >
n) {<BR><SPAN class=522153808-10112008> </SPAN>LM_ERR("Buffer
size overflow for body\n");<BR><SPAN class=522153808-10112008>
</SPAN>pkg_free(s);<BR><SPAN class=522153808-10112008>
</SPAN>return -1;<BR>}</FONT></DIV>
<DIV><SPAN class=522153808-10112008><FONT face=Arial
size=2>...</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2>pkg_free(s);</FONT></DIV>
<DIV><SPAN class=522153808-10112008><FONT face=Arial
size=2>[snip]</FONT></SPAN></DIV></FONT></DIV></BODY></HTML>