/[imapfilter]/imapfilter/memory.c
ViewVC logotype

Contents of /imapfilter/memory.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sat Nov 10 15:34:20 2001 UTC (22 years, 5 months ago) by lefcha
Branch: MAIN
CVS Tags: release-0_7
Branch point for: release-0_7-patches
Changes since 1.3: +1 -0 lines
File MIME type: text/plain
Indent to K&R style.

1 #include <stdlib.h>
2 #include <string.h>
3 #include <errno.h>
4
5 #include "imapfilter.h"
6
7
8 /*
9 * A malloc() that checks the results and dies in case of error.
10 */
11 void *xmalloc(size_t size)
12 {
13 void *ptr;
14
15 ptr = (void *) malloc(size);
16
17 if (!ptr)
18 fatal(ERROR_MEMORY_ALLOCATION,
19 "imapfilter: allocating memory; %s\n", strerror(errno));
20
21 return ptr;
22 }
23
24
25 /*
26 * A realloc() that checks the results and dies in case of error.
27 */
28 void *xrealloc(void *ptr, size_t size)
29 {
30 ptr = (void *) realloc(ptr, size);
31
32 if (!ptr)
33 fatal(ERROR_MEMORY_ALLOCATION,
34 "imapfilter: allocating memory; %s\n", strerror(errno));
35
36 return ptr;
37 }
38
39
40 /*
41 * A strdup() that checks the results and dies in case of error.
42 */
43 char *xstrdup(const char *s)
44 {
45 char *cp;
46
47 cp = strdup(s);
48
49 if (!cp)
50 fatal(ERROR_MEMORY_ALLOCATION,
51 "imapfilter: allocating memory; %s\n", strerror(errno));
52
53 return cp;
54 }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26