asprintf.c File Reference

GIS Library - GRASS implementation of asprintf(). More...

#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <assert.h>
#include <grass/gis.h>
Include dependency graph for asprintf.c:

Go to the source code of this file.

Defines

#define _GNU_SOURCE

Functions

int G_vasprintf (char **out, const char *fmt, va_list ap)
 Safe replacement for asprintf().
int G_asprintf (char **out, const char *fmt,...)

Detailed Description

GIS Library - GRASS implementation of asprintf().

Eric G. Miller - Thu, 2 May 2002 17:51:54 -0700

I've got a sort of cheat for asprintf. We can't use vsnprintf for the same reason we can't use snprintf ;-) Comments welcome.

We cheat by printing to a tempfile via vfprintf() and then reading it back in. Probably not the most efficient way.

WARNING: Temporarily, the G_asprintf macro cannot be used. See explanation in gisdefs.h.

(C) 2001-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author:
Eric Miller - egm2 at jps net
Date:
2002-2008

Definition in file asprintf.c.


Define Documentation

#define _GNU_SOURCE

Definition at line 28 of file asprintf.c.


Function Documentation

int G_asprintf ( char **  out,
const char *  fmt,
  ... 
)

Definition at line 116 of file asprintf.c.

References G_vasprintf().

int G_vasprintf ( char **  out,
const char *  fmt,
va_list  ap 
)

Safe replacement for asprintf().

Allocate a string large enough to hold the new output, including the terminating NULL, and returns a pointer to the first parameter. The pointer should be passed to G_free() to release the allocated storage when it is no longer needed.

Parameters:
[out] out 
[in] fmt 
Returns:
number of bytes written

Definition at line 66 of file asprintf.c.

References G_free(), and NULL.

Referenced by G_asprintf().


Generated on Sat Oct 24 03:24:48 2009 for GRASS Programmer's Manual by  doxygen 1.6.1