MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / cJSON_CreateNumber

Function cJSON_CreateNumber

ThirdParty/cjson/cJSON.c:2304–2328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2302}
2303
2304CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2305{
2306 cJSON *item = cJSON_New_Item(&global_hooks);
2307 if(item)
2308 {
2309 item->type = cJSON_Number;
2310 item->valuedouble = num;
2311
2312 /* use saturation in case of overflow */
2313 if (num >= INT_MAX)
2314 {
2315 item->valueint = INT_MAX;
2316 }
2317 else if (num <= (double)INT_MIN)
2318 {
2319 item->valueint = INT_MIN;
2320 }
2321 else
2322 {
2323 item->valueint = (int)num;
2324 }
2325 }
2326
2327 return item;
2328}
2329
2330CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2331{

Callers 4

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