MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / print_int

Function print_int

common/map_sdk/transmission/src/cJSON.cpp:154–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static char *print_int(cJSON *item) {
155 char *str;
156 str = reinterpret_cast<char *>(cJSON_malloc(22)); /* 2^64+1 can be represented in 21 chars. */
157 if (str) {
158 if (item->sign == -1) {
159 if (item->valueint <= static_cast<int64>(INT_MAX) && item->valueint >= static_cast<int64>(INT_MIN)) {
160 sprintf(str, "%d", static_cast<int32>(item->valueint));
161 } else {
162 sprintf(str, "%lld", static_cast<int64>(item->valueint));
163 }
164 } else {
165 if (item->valueint <= static_cast<uint64>(UINT_MAX)) {
166 sprintf(str, "%u", static_cast<uint32>(item->valueint));
167 } else {
168 sprintf(str, "%llu", item->valueint);
169 }
170 }
171 }
172 return str;
173}
174
175/* Parse the input text into an unescaped cstring, and populate item. */
176static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};

Callers 1

print_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected