38
#if defined(__LCLINT__)
39
/*@-declundef -incondefs @*/ /* LCL: missing annotation */
41
void * alloca (size_t __size)
42
/*@ensures MaxSet(result) == (__size - 1) @*/
46
/*@mayexit@*/ /*@only@*/ /*@out@*/ /*@unused@*/
47
void * xmalloc (size_t size)
49
/*@ensures maxSet(result) == (size - 1) @*/
50
/*@modifies errno @*/;
52
/*@mayexit@*/ /*@only@*/ /*@unused@*/
53
void * xcalloc (size_t nmemb, size_t size)
54
/*@ensures maxSet(result) == (nmemb - 1) @*/
44
/*@=declundef =incondefs @*/
47
/* AIX requires this to be the first thing in the file. */
55
# ifndef alloca /* predefined by HP cc +Olibcalls */
60
#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
61
#define alloca __builtin_alloca
57
/*@mayexit@*/ /*@only@*/ /*@unused@*/
58
void * xrealloc (/*@null@*/ /*@only@*/ void * ptr, size_t size)
59
/*@ensures maxSet(result) == (size - 1) @*/
65
62
/*@mayexit@*/ /*@only@*/ /*@unused@*/
66
63
char * xstrdup (const char *str)
70
#if HAVE_MCHECK_H && defined(__GNUC__)
67
#if !defined(HAVE_STPCPY)
68
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
69
static inline char * stpcpy (char *dest, const char * src) {
70
register char *d = dest;
71
register const char *s = src;
80
/* Memory allocation via macro defs to get meaningful locations from mtrace() */
81
#if defined(HAVE_MCHECK_H) && defined(__GNUC__)
71
82
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
83
#define xmalloc(_size) (malloc(_size) ? : vmefail())
84
#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
85
#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
72
86
#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
88
#define xmalloc(_size) malloc(_size)
89
#define xcalloc(_nmemb, _size) calloc((_nmemb), (_size))
90
#define xrealloc(_ptr, _size) realloc((_ptr), (_size))
74
91
#define xstrdup(_str) strdup(_str)
75
#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
92
#endif /* defined(HAVE_MCHECK_H) && defined(__GNUC__) */
77
#if HAVE___SECURE_GETENV && !defined(__LCLINT__)
94
#if defined(HAVE___SECURE_GETENV) && !defined(__LCLINT__)
78
95
#define getenv(_s) __secure_getenv(_s)
98
#if !defined(__GNUC__) && !defined(__attribute__)
99
#define __attribute__(x)
101
#define UNUSED(x) x __attribute__((__unused__))