Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 May 1996 03:49:45 -0700 (PDT)
From:      Peter Wemm <peter>
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
Message-ID:  <199605271049.DAA03239@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



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