From owner-cvs-lib Mon May 27 03:49:56 1996 Return-Path: owner-cvs-lib Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA03268 for cvs-lib-outgoing; Mon, 27 May 1996 03:49:56 -0700 (PDT) Received: (from peter@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA03239; Mon, 27 May 1996 03:49:45 -0700 (PDT) Date: Mon, 27 May 1996 03:49:45 -0700 (PDT) From: Peter Wemm Message-Id: <199605271049.DAA03239@freefall.freebsd.org> To: CVS-committers, cvs-all, cvs-lib, cvs-include Subject: cvs commit: src/include stdio.h src/lib/libc/stdio asprintf.c vasprintf.c Makefile.inc printf.3 Sender: owner-cvs-lib@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk peter 96/05/27 03:49:44 Modified: include stdio.h lib/libc/stdio Makefile.inc printf.3 Added: lib/libc/stdio asprintf.c vasprintf.c Log: Add an implementation of the gnu-ish asprintf() and vasprintf(). They are not based on gpl'ed code, just prototype and usage. I'm not 100% certain they behave the same while the system is in trouble (eg: malloc() failing) but in those circumstances all bets would be off anyway. These routines work like sprintf() and vsprintf(), except that instead of using a fixed buffer, they allocate memory and return it to the user and it's the user's responsibility to free() it. They have allocate as much memory as they need (and can get), so the size of strings it can deal with is limited only by the amount of memory it can malloc() on your behalf. There are a few gpl'ed programs starting to use this interface, and it's becoming more common with the scares about security risks with sprintf(). I dont like the look of the code that the various programs (including cvs, gdb, libg++, etc) provide if configure can't find it on the system. It should be possible to modify the stdio core code to provide this interface more efficiently, I was more worried about having something that worked and was secure. :-) (I noticed that there was once intended to be a smprintf() routine when our stdio was written for 4.4BSD, but it looks pretty stillborn, and it's intended interface is not clear). Since Linux and gnu libc have this interface, it seemed silly to bring yet another one onto the scene. Revision Changes Path 1.6 +2 -0 src/include/stdio.h 1.4 +5 -5 src/lib/libc/stdio/Makefile.inc 1.4 +47 -33 src/lib/libc/stdio/printf.3