1 |
root |
1.1 |
#include <cstdlib> |
2 |
|
|
#include <cstring> |
3 |
|
|
#include <inttypes.h> |
4 |
|
|
|
5 |
|
|
#include "rxvtutil.h" |
6 |
|
|
|
7 |
|
|
class byteorder byteorder; |
8 |
|
|
|
9 |
root |
1.2 |
unsigned int byteorder::e; |
10 |
|
|
|
11 |
root |
1.1 |
byteorder::byteorder () |
12 |
|
|
{ |
13 |
|
|
union { |
14 |
|
|
uint32_t u; |
15 |
|
|
uint8_t b[4]; |
16 |
|
|
} w; |
17 |
|
|
|
18 |
|
|
w.b[0] = 0x11; |
19 |
|
|
w.b[1] = 0x22; |
20 |
|
|
w.b[2] = 0x33; |
21 |
|
|
w.b[3] = 0x44; |
22 |
|
|
|
23 |
|
|
e = w.u; |
24 |
|
|
} |
25 |
|
|
|
26 |
root |
1.2 |
void * |
27 |
|
|
zero_initialized::operator new (size_t s) |
28 |
|
|
{ |
29 |
|
|
void *p = malloc (s); |
30 |
|
|
|
31 |
|
|
memset (p, 0, s); |
32 |
|
|
return p; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
void |
36 |
|
|
zero_initialized::operator delete (void *p, size_t s) |
37 |
|
|
{ |
38 |
|
|
free (p); |
39 |
|
|
} |
40 |
|
|
|
41 |
root |
1.3 |
static void *temp_buf; |
42 |
|
|
static uint32_t temp_len; |
43 |
|
|
|
44 |
|
|
void * |
45 |
|
|
rxvt_temp_buf (int len) |
46 |
|
|
{ |
47 |
|
|
if (len > temp_len) |
48 |
|
|
{ |
49 |
|
|
free (temp_buf); |
50 |
|
|
temp_buf = malloc (len); |
51 |
|
|
temp_len = len; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
return temp_buf; |
55 |
|
|
} |
56 |
root |
1.1 |
|
57 |
|
|
|