MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_CreateNumber

Function cJSON_CreateNumber

framework/utils/cJSON.c:2290–2314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2288}
2289
2290CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2291{
2292 cJSON *item = cJSON_New_Item(&global_hooks);
2293 if(item)
2294 {
2295 item->type = cJSON_Number;
2296 item->valuedouble = num;
2297
2298 /* use saturation in case of overflow */
2299 if (num >= INT_MAX)
2300 {
2301 item->valueint = INT_MAX;
2302 }
2303 else if (num <= INT_MIN)
2304 {
2305 item->valueint = INT_MIN;
2306 }
2307 else
2308 {
2309 item->valueint = (int)num;
2310 }
2311 }
2312
2313 return item;
2314}
2315
2316CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2317{

Callers 5

addInt64Method · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_CreateIntArrayFunction · 0.85
cJSON_CreateFloatArrayFunction · 0.85
cJSON_CreateDoubleArrayFunction · 0.85

Calls 1

cJSON_New_ItemFunction · 0.85

Tested by

no test coverage detected