PIPS
vasprintf.c File Reference
#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include "vasnprintf.h"
+ Include dependency graph for vasprintf.c:

Go to the source code of this file.

Functions

int vasprintf (char **resultp, const char *format, va_list args)
 Formatted output to strings. More...
 

Function Documentation

◆ vasprintf()

int vasprintf ( char **  resultp,
const char *  format,
va_list  args 
)

Formatted output to strings.

Copyright (C) 1999, 2002, 2006-2014 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.
Specification.

Return the number of resulting bytes, excluding the trailing NUL.

Definition at line 33 of file vasprintf.c.

34 {
35  size_t length;
36  char *result = vasnprintf (NULL, &length, format, args);
37  if (result == NULL)
38  return -1;
39 
40  if (length > INT_MAX)
41  {
42  free (result);
43  errno = EOVERFLOW;
44  return -1;
45  }
46 
47  *resultp = result;
48  /* Return the number of resulting bytes, excluding the trailing NUL. */
49  return length;
50 }
#define EOVERFLOW
Definition: errno.in.h:208
void free(void *)
char char * vasnprintf(char *resultbuf, size_t *lengthp, const char *format, va_list args) _GL_ATTRIBUTE_FORMAT((__printf__

References EOVERFLOW, free(), and vasnprintf().

Referenced by add_one_unformated_printf_to_text(), asprintf(), pips_log_alist(), pips_stop_alist(), pyps_error_handler(), pyps_log_handler(), safe_vasprintf(), and string_buffer_printf_alist().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: