Coverage Report

Created: 2026-06-15 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/uWebSockets/src/Utilities.h
Line
Count
Source
1
/*
2
 * Authored by Alex Hultman, 2018-2020.
3
 * Intellectual property of third-party.
4
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
#ifndef UWS_UTILITIES_H
19
#define UWS_UTILITIES_H
20
21
/* Various common utilities */
22
23
#include <cstdint>
24
25
namespace uWS {
26
namespace utils {
27
28
5.77k
inline int u32toaHex(uint32_t value, char *dst) {
29
5.77k
    char palette[] = "0123456789abcdef";
30
5.77k
    char temp[10];
31
5.77k
    char *p = temp;
32
5.97k
    do {
33
5.97k
        *p++ = palette[value & 15];
34
5.97k
        value >>= 4;
35
5.97k
    } while (value > 0);
36
37
5.77k
    int ret = (int) (p - temp);
38
39
5.97k
    do {
40
5.97k
        *dst++ = *--p;
41
5.97k
    } while (p != temp);
42
43
5.77k
    return ret;
44
5.77k
}
45
46
97.3k
inline int u64toa(uint64_t value, char *dst) {
47
97.3k
    char temp[20];
48
97.3k
    char *p = temp;
49
191k
    do {
50
191k
        *p++ = (char) ((value % 10) + '0');
51
191k
        value /= 10;
52
191k
    } while (value > 0);
53
54
97.3k
    int ret = (int) (p - temp);
55
56
191k
    do {
57
191k
        *dst++ = *--p;
58
191k
    } while (p != temp);
59
60
97.3k
    return ret;
61
97.3k
}
62
63
}
64
}
65
66
#endif // UWS_UTILITIES_H