AW: [En-Nut-Discussion] Need Help on URL Parse

Oliver Schulz olischulz at web.de
Mon Jul 26 20:59:27 CEST 2004


Hi,
    url = NutHeapAlloc(128);
    temp = NutHeapAlloc(128);
       strcpy(temp,"192.168.125.0:800/index.html");
       cp = strtok_r(temp,":",&url);
       printf("IP%s\n",cp);

    NutHeapFree(url);
    NutHeapFree(temp);

  This program will loss around 20-30Byte of the memory everytime it
execute.
  Any idea how to solve this problem ?

  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.
  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...

  Cheers,
  Oliver.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20040726/5b5de3b4/attachment-0001.html>


More information about the En-Nut-Discussion mailing list