ekg2  GIT master
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 #include <limits.h>
29 
30 #define __(x) (x ? x : "(null)")
31 
32 /* stolen from: http://sourcefrog.net/weblog/software/languages/C/unused.html */
33 #ifdef UNUSED
34 #elif defined(__GNUC__)
35 # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
36 #elif defined(__LCLINT__)
37 # define UNUSED(x) /*@unused@*/ x
38 #else
39 # define UNUSED(x) x
40 #endif
41 /* /stolen */
42 
43 #ifndef HAVE_SOCKLEN_T
44 typedef unsigned int socklen_t;
45 #endif
46 
47 /* buffer lengths in stuff.c */
48 #ifndef PATH_MAX
49 # ifdef MAX_PATH
50 # define PATH_MAX MAX_PATH
51 # else
52 # ifdef _POSIX_PATH_MAX
53 # define PATH_MAX _POSIX_PATH_MAX
54 # else
55 # define PATH_MAX 4096
56 # endif
57 # endif
58 #endif
59 
60 #ifndef EKG2_WIN32_NOFUNCTION
61 
62 #ifndef EKG_NO_DEPRECATED
63 void *xcalloc(size_t nmemb, size_t size);
64 void *xmalloc(size_t size);
65 void xfree(void *ptr);
66 void *xrealloc(void *ptr, size_t size);
67 char *xstrdup(const char *s);
68 char *xstrndup(const char *s, size_t n);
69 #endif
70 char *utf8ndup(const char *s, size_t n);
71 
72 int xstrcasecmp(const char *s1, const char *s2);
73 char *xstrcat(char *dest, const char *src);
74 char *xstrchr(const char *s, int c);
75 int xstrcmp(const char *s1, const char *s2);
76 int xstrcoll(const char *s1, const char *s2);
77 char *xstrcpy(char *dest, const char *src);
78 size_t xstrcspn(const char *s, const char *reject);
79 size_t xstrlen(const char *s);
80 int xstrncasecmp_pl(const char *s1, const char *s2, size_t n);
81 char *xstrncat(char *dest, const char *src, size_t n);
82 int xstrncmp(const char *s1, const char *s2, size_t n);
83 char *xstrncpy(char *dest, const char *src, size_t n);
84 int xstrncasecmp(const char *s1, const char *s2, size_t n);
85 char *xstrpbrk(const char *s, const char *accept);
86 char *xstrrchr(const char *s, int c);
87 /*
88 char *xstrsep(char **stringp, const char *delim);
89 */
90 size_t xstrspn(const char *s, const char *accept);
91 char *xstrstr(const char *haystack, const char *needle);
92 char *xstrcasestr(const char *haystack, const char *needle);
93 char *xstrtok(char *s, const char *delim);
94 char *xindex(const char *s, int c);
95 char *xrindex(const char *s, int c);
96 
97 #ifndef EKG_NO_DEPRECATED
98 
99 char *vsaprintf(const char *format, va_list ap);
100 
101  /* stuff.h */
102 #ifdef __GNUC__
103 char *saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
104 #else
105 char *saprintf(const char *format, ...);
106 #endif
107 #endif
108 
109 #endif
110 
111 #endif /* __EKG_XMALLOC_H */
112 
113 /*
114  * Local Variables:
115  * mode: c
116  * c-file-style: "k&r"
117  * c-basic-offset: 8
118  * indent-tabs-mode: t
119  * End:
120  */
int xstrncmp(const char *s1, const char *s2, size_t n)
Definition: xmalloc.c:238
size_t xstrspn(const char *s, const char *accept)
Definition: xmalloc.c:272
unsigned int socklen_t
Definition: xmalloc.h:44
char * xstrpbrk(const char *s, const char *accept)
Definition: xmalloc.c:253
Definition: ekg_hash_benchmark.c:47
void xfree(void *ptr)
Definition: ekg_hash_benchmark.c:29
void * xmalloc(size_t size)
Definition: ekg_hash_benchmark.c:25
size_t xstrcspn(const char *s, const char *reject)
Definition: xmalloc.c:218
int xstrcoll(const char *s1, const char *s2)
Definition: xmalloc.c:208
Definition: rivchat.h:42
char * xstrrchr(const char *s, int c)
Definition: xmalloc.c:258
char * xstrncat(char *dest, const char *src, size_t n)
Definition: xmalloc.c:233
char * xstrcpy(char *dest, const char *src)
Definition: xmalloc.c:213
void * xrealloc(void *ptr, size_t size)
Definition: xmalloc.c:116
char * xstrtok(char *s, const char *delim)
Definition: xmalloc.c:277
char * xindex(const char *s, int c)
Definition: xmalloc.c:283
char * vsaprintf(const char *format, va_list ap)
Definition: xmalloc.c:168
char * xstrstr(const char *haystack, const char *needle)
Definition: xmalloc.c:177
size_t xstrlen(const char *s)
Definition: xmalloc.c:223
int xstrncasecmp_pl(const char *s1, const char *s2, size_t n)
Definition: xmalloc.c:228
char * utf8ndup(const char *s, size_t n)
Definition: xmalloc.c:145
int xstrcasecmp(const char *s1, const char *s2)
Definition: xmalloc.c:187
char * xstrdup(const char *s)
Definition: ekg_hash_benchmark.c:28
void * xcalloc(size_t nmemb, size_t size)
Definition: xmalloc.c:63
char * saprintf(const char *format,...)
Definition: stuff.c:2369
char * xrindex(const char *s, int c)
Definition: xmalloc.c:292
char * xstrndup(const char *s, size_t n)
Definition: xmalloc.c:136
char * xstrncpy(char *dest, const char *src, size_t n)
Definition: xmalloc.c:243
char * xstrchr(const char *s, int c)
Definition: xmalloc.c:197
#define s
int xstrncasecmp(const char *s1, const char *s2, size_t n)
Definition: xmalloc.c:248
int xstrcmp(const char *s1, const char *s2)
Definition: ekg_hash_benchmark.c:27
char * xstrcat(char *dest, const char *src)
Definition: xmalloc.c:192
char * xstrcasestr(const char *haystack, const char *needle)
Definition: xmalloc.c:182