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). ...
  • 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. ...
  • 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. ...
  • 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, ...
  • Re: Memory leak when internal pointer passed out as parameter
    ... new block of memory when foo1 returns. ... within foo1 will remain in the system heap forever. ... The allocated memory will be returned to the system heap when the ... free the memory when the program exits, ...