Rockbox mail archiveSubject: Re: strtok_r problem
Re: strtok_r problem
From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 30 Jan 2003 06:57:31 +0100 (CET)
On Wed, 29 Jan 2003, Benjamin wrote:
A general reflection on this problem is that this case explains exactly why
you want your code to run and get evaluated in the simulator first, as then
debugging things like this is pretty easy... I've never understood how you
Windows-people manage without it.
Remarks on the code:
* bookmark_get_next_field() is overly exessive and both sets and copies huge
chunks of memory on each call. I can't see any obvious error in your use of
strtok_r() other than I think you should solve the repeated invokes in a
loop or similar.
* Boundary checks! Your code assumes all-over that strings will fit within
the buffers you consider the maximum sizes. Don't assume, check!
* Indentation. We use 4 spaces. You use 3 and 4 mixed at various places.
* Variables first, then code. We try to be C89 compliant, and having variable
declarations mixed with code is not.
* Don't you think there will be any mp3 songs using '*' in the title? You
can't blindly assume there won't. Also, if there would be a title longer
than MAX_PATH in a bookmark, you overflow the buffer.
* Please don't use CRLF newlines in the code.
Sorry for not having actually run this to find any bugs.
-- Daniel Stenberg -- http://rockbox.haxx.se/ -- http://daniel.haxx.se/Received on 2003-01-30