avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Re: Request for cbrt() and strdup to be added to libc


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] Re: Request for cbrt() and strdup to be added to libc
Date: Sun, 22 Jun 2008 22:08:32 +0200
User-agent: Mutt/1.5.11

As Andy H wrote:

> double cbrt(const double x)
> 
> {
> return pow(x,1.0/3.0);
> }

If cbrt() is going to be more than just an alibi function to make GCC
tests happy, then it should probably be implemented similar to the
existing libm functions.

> char *  strdup( const char *str)
> {
>        unsigned int len;

That ought to be size_t.

>        char *copy;
>        len = strlen(str) + 1;
>        copy = malloc(len);
>        if (!copy)
>                return (copy);

It would be interesting to see whether the more readable version:

        if (copy == NULL)
                return NULL;

generates the same (or less) code.

>        memcpy(copy, str, len);

Better copy len+1 so the trailing \0 will be copied as well.

However, that's only half of the story, and the other half is
frequently forgotten about by people sending patches (and wondering
why it takes forever to integrate them): the documentation is missing.
Sure, it's peanuts, and obvious -- but it adds up.  When being shortly
before a release, and (as usual) in time pressure, and having to ask
myself which patches still could go in and which cannot because I'm
completely out of time for the job, patches that do have documentation
will always be the first to consider.  Writing up documentation for a
couple of functions, test-driving doxygen on it, reviewing the result,
and tweaking it for optimal appearance easily takes another half an
hour or more.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]