Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 May 2001 19:37:54 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        Daniel Hemmerich <dan@BSDpro.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: adding a new function to libc
Message-ID:  <20010512193754.A47253@xor.obsecurity.org>
In-Reply-To: <01051202104500.95296@blackhole.BSDpro.com>; from dan@BSDpro.com on Sat, May 12, 2001 at 02:10:45AM -0400
References:  <01051202104500.95296@blackhole.BSDpro.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, May 12, 2001 at 02:10:45AM -0400, Daniel Hemmerich wrote:
> Any comments, suggestions, swears concerning adding a new function,=20
> strndup(), to libc?
>=20
> So that instead of permitting it to attempt to allocate a large chunk of=
=20
> memory, it is possible to give it a max length.

#include <stdio.h>

int main(int argc, char **argv) {
        char *p;

        asprintf(&p, "%.*s", 100, argv[1]);
        printf("%s %d\n", p, strlen(p));
}

Kris

--KsGdsel6WgEHnImy
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE6/fOBWry0BWjoQKURAhMTAKDyzA+tsHhVYVBpJwQQIFqvhdf+cgCeI02s
5t8WOV+SaBoyO2tE3FzM/Pg=
=EThX
-----END PGP SIGNATURE-----

--KsGdsel6WgEHnImy--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010512193754.A47253>