GDB (API)
/home/stan/gdb/src/gdb/common/common-utils.h
Go to the documentation of this file.
00001 /* Shared general utility routines for GDB, the GNU debugger.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #ifndef COMMON_UTILS_H
00021 #define COMMON_UTILS_H
00022 
00023 #include "config.h"
00024 #include "ansidecl.h"
00025 #include <stddef.h>
00026 #include <stdarg.h>
00027 
00028 extern void malloc_failure (long size) ATTRIBUTE_NORETURN;
00029 extern void internal_error (const char *file, int line, const char *, ...)
00030      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
00031 
00032 /* xmalloc(), xrealloc() and xcalloc() have already been declared in
00033    "libiberty.h". */
00034 
00035 /* Like xmalloc, but zero the memory.  */
00036 void *xzalloc (size_t);
00037 
00038 void xfree (void *);
00039 
00040 /* Like asprintf and vasprintf, but return the string, throw an error
00041    if no memory.  */
00042 char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
00043 char *xstrvprintf (const char *format, va_list ap)
00044      ATTRIBUTE_PRINTF (1, 0);
00045 
00046 /* Like snprintf, but throw an error if the output buffer is too small.  */
00047 int xsnprintf (char *str, size_t size, const char *format, ...)
00048      ATTRIBUTE_PRINTF (3, 4);
00049 
00050 /* Make a copy of the string at PTR with LEN characters
00051    (and add a null character at the end in the copy).
00052    Uses malloc to get the space.  Returns the address of the copy.  */
00053 
00054 char *savestring (const char *ptr, size_t len);
00055 
00056 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines