<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff
size=2>Hi,</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=Arial size=2> url = NutHeapAlloc(128); <BR>
temp = NutHeapAlloc(128); <BR>
strcpy(temp,"192.168.125.0:800/index.html");<BR> cp =
strtok_r(temp,":",&url);<BR>
printf("IP%s\n",cp);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> NutHeapFree(url);<BR>
NutHeapFree(temp);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>This program will loss around 20-30Byte of the
memory everytime it execute.</FONT></DIV>
<DIV><FONT face=Arial size=2>Any idea how to solve this problem ?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff size=2>As
far as I can understand the function strtok_r, it's wrong to allocate memory
for the variable 'url', because it is just used as a pointer for subsequent
calls to strtok_r.</FONT></SPAN></DIV>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff size=2>The
function modifies the value of 'url', so if you use NutHeapFree on url after a
call to strtok_r, the system frees something else but not the allocated mem...
</FONT></SPAN></DIV>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff
size=2>Cheers,</FONT></SPAN></DIV>
<DIV><SPAN class=812085618-26072004><FONT face=Arial color=#0000ff
size=2>Oliver.</FONT></SPAN></DIV></BLOCKQUOTE></BODY></HTML>