On Wed, Jan 17, 2001 at 11:45:08AM +0100, Juergen Schoenwaelder wrote:
> It is IMHO the job of the libc coders to make strdup() and everything
> else fast (and I think some libc's do real magic to achieve this).

Are there any platforms with a libc that does anything fancier in
"strdup()" than

        char *
        strdup(str)
                const char *str;
        {
                size_t len;
                char *copy;

                len = strlen(str) + 1;
                if ((copy = malloc(len)) == NULL)
                        return (NULL);
                memcpy(copy, str, len);
                return (copy);
        }

(FreeBSD 3.4, but this is probably just the 4.4-Lite one), or

        char *
        __strdup (const char *s)
        {
          size_t len = strlen (s) + 1;
          void *new = malloc (len);

          if (new == NULL)
            return NULL;

          return (char *) memcpy (new, s, len);
        }

(glibc 2.1.2)?

There may also be cases where the libc routine's goal is to handle a
large number of cases well and, as a result, it may not handle some
cases as efficiently as it could if it were optimized only for those
cases.  Replacing that routine *could* make a difference to some
applications.

In this particular case, "savestr()" didn't seem to speed things up on
the capture file on which I tried it; I don't know whether the LBL guys
had some application where it *did* make a difference, and just started
using "savestr()" everywhere even where it didn't make a difference, or
whether they somehow had a case where it made a difference to tcpdump,
or what.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

Reply via email to