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>
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,...) |
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.
Definition in file asprintf.c.
#define _GNU_SOURCE |
Definition at line 28 of file asprintf.c.
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.
[out] | out | |
[in] | fmt |
Definition at line 66 of file asprintf.c.
References G_free().
Referenced by G_asprintf().