Re: strtok buffer question




soccertl wrote:
From looking at the source code it looks like tsdalloc allocates memory
with lmalloc but it is not clear when this memory gets freed. This
makes me worried that the caller is suppose to do something to free
this memory but I have not seen that mentioned anywhere.

I wasn't aware that strtok actually allocated memory.

Well, I found a different strtok in the open source link that I think
works more like I expected. It doesn't allocate memory and just saves
the pointer in a static variable. That makes more sense and I see how
it works now.

.



Relevant Pages

  • Re: How to take in a string of any size?
    ... >the contents into the allocated memory. ... nobody said the string started at the beginning of the file. ... >number of calls to realloc() isn't going to be excessive). ...
    (comp.lang.c)
  • Re: Interprocess Communication & Performance
    ... For instance if the data items are small and ... memory the performance hit from the synchronization will overwhelm things. ... to map the allocated memory in both processes. ... memcpy's then using shared file mapping I think. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: will I get Memory leak..
    ... dynamically assigned memory area will i get memory leak.. ... The problem with your code, on the other hand, is that your call to strcpywrites a null character to fp, which is one position past the end of the allocated memory. ... As a result of that error, the behavior of your entire program is undefined, which means that anything could go wrong A memory leak is very definitely a possibility from making that kind of mistake, but most of the other possible consequences of that mistake are much worse than memory leaks. ...
    (comp.lang.c)
  • Re: [PATVH] media, dvb, IX2505V: Remember to free allocated memory in failure path (ix2505v_attach()
    ... We may leak the storage allocated to 'state' in ... This patch makes sure we free the allocated memory in the failure case. ... const struct ix2505v_config *config, ...
    (Linux-Kernel)
  • Re: [PATVH] media, dvb, IX2505V: Remember to free allocated memory in failure path (ix2505v_attach()
    ... We may leak the storage allocated to 'state' in ... This patch makes sure we free the allocated memory in the failure case. ...
    (Linux-Kernel)