view lib/xvasprintf.c @ 5940:5e3f37f5f1d4

2005-06-25 Simon Josefsson <jas@extundo.com> * modules/check-version: New file.
author Simon Josefsson <simon@josefsson.org>
date Tue, 28 Jun 2005 09:50:35 +0000
parents a48fb0e98c8c
children 1807d27bf1ec
line wrap: on
line source

/* vasprintf and asprintf with out-of-memory checking.
   Copyright (C) 1999, 2002-2004 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 2, 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, write to the Free Software Foundation,
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* Specification.  */
#include "xvasprintf.h"

#include <errno.h>

#include "vasprintf.h"
#include "xalloc.h"

char *
xvasprintf (const char *format, va_list args)
{
  char *result;

  if (vasprintf (&result, format, args) < 0)
    {
      if (errno == ENOMEM)
	xalloc_die ();
      return NULL;
    }

  return result;
}