op_libiberty.h

Go to the documentation of this file.
00001 
00013 #ifndef OP_LIBIBERTY_H
00014 #define OP_LIBIBERTY_H
00015 
00016 #include <stddef.h>
00017 
00018 #include "config.h"
00019 
00020 #ifdef MALLOC_ATTRIBUTE_OK
00021 #define OP_ATTRIB_MALLOC    __attribute__((malloc))
00022 #else
00023 #define OP_ATTRIB_MALLOC
00024 #endif
00025 
00026 #ifdef HAVE_LIBIBERTY_H
00027 #include <libiberty.h>
00028 #else
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /* some system have a libiberty.a but no libiberty.h so we must provide
00035  * ourself the missing proto */
00036 #ifndef HAVE_LIBIBERTY_H
00037 /* Set the program name used by xmalloc.  */
00038 void xmalloc_set_program_name(char const *);
00039 
00040 /* Allocate memory without fail.  If malloc fails, this will print a
00041    message to stderr (using the name set by xmalloc_set_program_name,
00042    if any) and then call xexit.  */
00043 void * xmalloc(size_t) OP_ATTRIB_MALLOC;
00044 
00045 /* Reallocate memory without fail.  This works like xmalloc.  Note,
00046    realloc type functions are not suitable for attribute malloc since
00047    they may return the same address across multiple calls. */
00048 void * xrealloc(void *, size_t);
00049 
00050 /* Allocate memory without fail and set it to zero.  This works like xmalloc */
00051 void * xcalloc(size_t, size_t) OP_ATTRIB_MALLOC;
00052 
00053 /* Copy a string into a memory buffer without fail.  */
00054 char * xstrdup(char const *) OP_ATTRIB_MALLOC;
00055 
00062 void * xmemdup(void const *, size_t, size_t) OP_ATTRIB_MALLOC;
00063 
00064 #endif  /* !HAVE_LIBIBERTY_H */
00065 
00066 #ifdef __cplusplus
00067 }
00068 #endif
00069 
00070 #endif /* !HAVE_LIBIBERTY_H */
00071 
00072 #endif /* OP_LIBIBERTY_H */

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1