delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2008/03/04/04:13:45

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
From: Martin Str|mberg <ams AT ludd DOT ltu DOT se>
Message-Id: <200803040848.m248mCia026383@brother.ludd.ltu.se>
Subject: Re: asprintf and vasprintf implementation
To: djgpp-workers AT delorie DOT com
Date: Tue, 4 Mar 2008 09:48:12 +0100 (MET)
In-Reply-To: <200803031657.57524.juan.guerrero@gmx.de> from "Juan Manuel Guerrero" at Mar 03, 2008 04:57:57 PM
X-Mailer: ELM [version 2.5 PL6]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Juan Manuel Guerrero:
> I have implemented asprintf() and vasprintf() that I have missed last time that

Thank you.

Just a minor improvement.

...
> diff -aprNU3 djgpp.orig/src/libc/compat/stdio/asprintf.txh djgpp/src/libc/compat/stdio/asprintf.txh
> --- djgpp.orig/src/libc/compat/stdio/asprintf.txh	1970-01-01 00:00:00 +0000
> +++ djgpp/src/libc/compat/stdio/asprintf.txh	2008-03-03 16:36:08 +0000
...
> +@subheading Description
> +
> +Sends formatted output from the arguments (@dots{}) including
> +the terminating null byte to the allocated buffer and returns
> +a pointer to it via the pointer *@var{bufferp}.   This memory
> +must be returned to the heap with @code{free} (@pxref{free}). 
> +This function is analog of @code{sprintf()} (@pxref{sprintf}).
...
> +@subheading Example
> +
> +@example
> +char *strbuf;
> +int strlen;
> +long double pi = 3.1415926535897932384626433832795;
> +
> +strlen = asprintf(&strbuf, "Pi = %.15Lf\n", pi);

Add "printf("Length = %d.\n", strlen);
     if( NULL != strbuf )
     {
	printf("strbuf = '%s'.\n", strbuf);
	free( strbuf );
     }
     else
     {
       	printf("strbuf = NULL.\n");
     }" or similar code.


-- 
MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019