ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
xmalloc.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl>
5  * 2004 Piotr Kupisiewicz <deli@rzepaknet.us>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License Version 2 as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef __EKG_XMALLOC_H
22 #define __EKG_XMALLOC_H
23 
24 #include <sys/types.h>
25 #include <stddef.h>
26 #include <stdarg.h>
27 
28 #ifndef __USE_POSIX
29  #define __USE_POSIX 1 /* glibc 2.8 */
30 #endif
31 #ifndef _XOPEN_SOURCE
32  #define _XOPEN_SOURCE 600
33 #endif
34 #include <limits.h>
35 
36 #define __(x) (x ? x : "(null)")
37 
38 /* stolen from: http://sourcefrog.net/weblog/software/languages/C/unused.html */
39 #ifdef UNUSED
40 #elif defined(__GNUC__)
41 # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
42 #elif defined(__LCLINT__)
43 # define UNUSED(x) /*@unused@*/ x
44 #else
45 # define UNUSED(x) x
46 #endif
47 /* /stolen */
48 
49 #ifndef HAVE_SOCKLEN_T
50 typedef unsigned int socklen_t;
51 #endif
52 
53 /* buffer lengths in stuff.c */
54 #ifndef PATH_MAX
55 # ifdef MAX_PATH
56 # define PATH_MAX MAX_PATH
57 # else
58 # ifdef _POSIX_PATH_MAX
59 # define PATH_MAX _POSIX_PATH_MAX
60 # else
61 # define PATH_MAX 4096
62 # endif
63 # endif
64 #endif
65 
66 #ifndef EKG2_WIN32_NOFUNCTION
67 
68 void ekg_oom_handler();
69 
70 void *xcalloc(size_t nmemb, size_t size);
71 void *xmalloc(size_t size);
72 void xfree(void *ptr);
73 void *xrealloc(void *ptr, size_t size);
74 char *xstrdup(const char *s);
75 size_t xstrnlen(const char *s, size_t n);
76 char *xstrndup(const char *s, size_t n);
77 char *utf8ndup(const char *s, size_t n);
78 void *xmemdup(void *ptr, size_t size);
79 
80 int xstrcasecmp(const char *s1, const char *s2);
81 char *xstrcat(char *dest, const char *src);
82 char *xstrchr(const char *s, int c);
83 int xstrcmp(const char *s1, const char *s2);
84 int xstrcoll(const char *s1, const char *s2);
85 char *xstrcpy(char *dest, const char *src);
86 size_t xstrcspn(const char *s, const char *reject);
87 char *xstrfry(char *string);
88 size_t xstrlen(const char *s);
89 int xstrncasecmp_pl(const char *s1, const char *s2, size_t n);
90 char *xstrncat(char *dest, const char *src, size_t n);
91 int xstrncmp(const char *s1, const char *s2, size_t n);
92 char *xstrncpy(char *dest, const char *src, size_t n);
93 int xstrncasecmp(const char *s1, const char *s2, size_t n);
94 char *xstrpbrk(const char *s, const char *accept);
95 char *xstrrchr(const char *s, int c);
96 /*
97 char *xstrsep(char **stringp, const char *delim);
98 */
99 size_t xstrspn(const char *s, const char *accept);
100 char *xstrstr(const char *haystack, const char *needle);
101 char *xstrcasestr(const char *haystack, const char *needle);
102 char *xstrtok(char *s, const char *delim);
103 char *xindex(const char *s, int c);
104 char *xrindex(const char *s, int c);
105 
106 char *vsaprintf(const char *format, va_list ap);
107 
108  /* stuff.h */
109 #ifdef __GNUC__
110 char *saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
111 #else
112 char *saprintf(const char *format, ...);
113 #endif
114 #endif
115 
116 
117 #endif /* __EKG_XMALLOC_H */
118 
119 /*
120  * Local Variables:
121  * mode: c
122  * c-file-style: "k&r"
123  * c-basic-offset: 8
124  * indent-tabs-mode: t
125  * End:
126  */