gdb/
[deliverable/binutils-gdb.git] / gdb / common / common-utils.h
CommitLineData
d26e3629
KY
1/* Shared general utility routines for GDB, the GNU debugger.
2
3 Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
4 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
5 2009, 2010, 2011 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22#ifndef COMMON_UTILS_H
23#define COMMON_UTILS_H
24
25#include "config.h"
26#include "ansidecl.h"
27#include <stddef.h>
28#include <stdarg.h>
29
30extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
31extern void internal_error (const char *file, int line, const char *, ...)
32 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
33
34/* xmalloc(), xrealloc() and xcalloc() have already been declared in
35 "libiberty.h". */
36
37/* Like xmalloc, but zero the memory. */
38void *xzalloc (size_t);
39
40void xfree (void *);
41
42/* Like asprintf and vasprintf, but return the string, throw an error
43 if no memory. */
44char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
45char *xstrvprintf (const char *format, va_list ap)
46 ATTRIBUTE_PRINTF (1, 0);
47
48/* Like asprintf/vasprintf but get an internal_error if the call
49 fails. */
50void xasprintf (char **ret, const char *format, ...)
51 ATTRIBUTE_PRINTF (2, 3);
52void xvasprintf (char **ret, const char *format, va_list ap)
53 ATTRIBUTE_PRINTF (2, 0);
54
55/* Like snprintf, but throw an error if the output buffer is too small. */
56int xsnprintf (char *str, size_t size, const char *format, ...)
57 ATTRIBUTE_PRINTF (3, 4);
58
59#endif
This page took 0.036041 seconds and 4 git commands to generate.