Loading...
Searching...
No Matches
asprintf.c File Reference

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

`#include <stdio.h>`
`#include <stdarg.h>`
`#include <string.h>`
`#include <grass/gis.h>`
Include dependency graph for asprintf.c:

Go to the source code of this file.

## Macros

#define | _GNU_SOURCE /* enable asprintf */

## Functions

int | G_vasprintf (char **out, const char *fmt, va_list ap)
| Safe replacement for asprintf().
int | G_asprintf (char **out, const char *fmt,...)
int | G_rasprintf (char **out, size_t *size, const char *fmt,...)
| Reallocating version of asprintf().

## Detailed Description

GIS Library - GRASS implementation of asprintf().

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

Rewritten by Glynn Clements, Sat, 6 Feb 2010 Assumes that vsnprintf() is available

(C) 2002-2014 by the GRASS Development Team (C) 2010 by Glynn Clements

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.

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE /* enable asprintf */

Definition at line 18 of file asprintf.c.

## Function Documentation

## G_asprintf()

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

Definition at line 68 of file asprintf.c.

References count, and G_vasprintf().

Referenced by G_define_standard_option(), G_get_projsrid(), G_parser(), get_pj_area(), get_pj_type_string(), GPJ__get_datum_params(), GPJ__get_ellipsoid_params(), GPJ_get_datum_transform_by_name(), GPJ_grass_to_osr(), GPJ_init_transform(), GPJ_osr_to_grass(), GPJ_set_csv_loc(), and M_define_option().

## G_rasprintf()

int G_rasprintf | ( | char ** | out,
|  | size_t * | size,
|  | const char * | fmt,
|  |  | ... )

Reallocating version of asprintf().

Reallocate a string large enough to hold the output, including the terminating NULL, and return the number of characters printed. Contrary to G_asprintf(), any existing buffer pointed to by out of size osize is used to hold the output and enlarged if necessary. This is useful when G_rasprintf is called many times in a loop.

Parameters

  [out] | out |
  [out] | size |
  [in] | fmt |
  | ap |

Returns
  number of bytes written

Definition at line 98 of file asprintf.c.

References count.

## 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 return the number of characters printed. The pointer out is set to the output string and should be passed to G_free() to release the allocated storage when it is no longer needed.

Parameters

  [out] | out |
  [in] | fmt |
  | ap |

Returns
  number of bytes written

Definition at line 40 of file asprintf.c.

References count.

Referenced by G_asprintf().