[CC: [EMAIL PROTECTED]

On Monday 07 July 2008 21:31, [EMAIL PROTECTED] wrote:
> Please, comment and consider applying.

+static void FAST_FUNC replace(char *s, char what, char with)

You do not need FAST_FUNCs on static functions. gcc does it itself.
At least I try to believe gcc will pick the most optimal ABI
for them without help...

+char FAST_FUNC **parse_config(
+       const char *filename,   // name of config file to parse
+       int ntokens,            // required amount of tokens, remainder to be 
returned verbatim
+                               // just set to big number
...
+       char **tokens = xzalloc(128 * sizeof(char *) *
+               (ntokens /* required tokens */ + 1 /* 
end-of-tokens-on-this-line marker*/));

Guess what "big number" users will put there? INT_MAX.

+               line = strtok(s, "\n"); // N.B. s != NULL only the first time
+               if (!line)
+                       break;

strtok uses static storage. I want to get rid of it eventually.
Maybe strsep?


+               replace(line, '#', '\0');

*strchrnul(line, '#') = '\0'. replace will do useless work
after first '#'.

+               // skip comments and empty lines
+               line = skip_whitespace(line);
+               if (!line)
+                       continue;

I think it had to be if (!*line).

+                       // pin token
+                       // FIXME: realloc!!!
+                       *token++ = s;

realloc indeed. I find this to be a useful idiom:
        if (!(idx & 0xfff)) {
                vector = xrealloc(vector, sizeof(vector[0]) * (idx + 0x1001));
Another libbb candidate?


+               token++; // xzmalloc guarantees NULL

it's "xzalloc" :)
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to