bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] xalloc: add xstrndup


From: Paul Eggert
Subject: Re: [Bug-gnulib] xalloc: add xstrndup
Date: 14 Aug 2003 20:10:19 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Simon Josefsson <address@hidden> writes:

> I did not include MODULES.html.sh documentation since xmalloc,
> xstrdup, etc was not mentioned.

It shouldn't be necessary, since the info is gotten from modules/xalloc.

> +  /* FIXME we may allocate more than needed amount. however strlen()
> +     may read out of bounds in case string is not zero terminated.
> +     looping through string (limited by n) waste cpu, this waste
> +     memory. */

Why not do something like this instead?

        char *s = strndup (string, n);
        if (! s)
          xalloc_die ();
        return s;




reply via email to

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