blob: 77c168f7ea983f4255e8961921e1d631dce5f851 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include <X11/X.h>
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
/*
* Utility functions required by libxf86_os.
*/
pointer
Xalloc(unsigned long n)
{
if (!n)
n = 1;
return malloc(n);
}
pointer
Xrealloc(pointer p, unsigned long n)
{
if (!n)
n = 1;
return realloc(p, n);
}
pointer
Xcalloc(unsigned long n)
{
pointer r;
r = Xalloc(n);
memset(r, 0, n);
return r;
}
pointer
XNFalloc(unsigned long n)
{
pointer r;
r = Xalloc(n);
if (!r)
FatalError("XNFalloc failed\n");
return r;
}
pointer
XNFrealloc(pointer p, unsigned long n)
{
pointer r;
r = Xrealloc(p, n);
if (!r)
FatalError("XNFrealloc failed\n");
return r;
}
pointer
XNFcalloc(unsigned long n)
{
pointer r;
r = Xcalloc(n);
if (!r)
FatalError("XNFcalloc failed\n");
return r;
}
void
Xfree(pointer p)
{
free(p);
}
char *
Xstrdup(const char *s)
{
char *sd;
if (s == NULL)
return NULL;
sd = (char *)Xalloc(strlen(s) + 1);
if (sd != NULL)
strcpy(sd, s);
return sd;
}
char *
XNFstrdup(const char *s)
{
char *sd;
size_t len;
if (s == NULL)
return NULL;
len = strlen(s) + 1;
sd = (char *)XNFalloc(len);
strlcpy(sd, s, len);
return sd;
}
|