| 2438 | } |
| 2439 | |
| 2440 | CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) |
| 2441 | { |
| 2442 | cJSON *item = cJSON_New_Item(&global_hooks); |
| 2443 | if(item) |
| 2444 | { |
| 2445 | item->type = cJSON_Number; |
| 2446 | item->valuedouble = num; |
| 2447 | |
| 2448 | /* use saturation in case of overflow */ |
| 2449 | if (num >= LLONG_MAX) |
| 2450 | { |
| 2451 | item->valueint = LLONG_MAX; |
| 2452 | } |
| 2453 | else if (num <= (double)LLONG_MIN) |
| 2454 | { |
| 2455 | item->valueint = LLONG_MIN; |
| 2456 | } |
| 2457 | else |
| 2458 | { |
| 2459 | item->valueint = (int64_t)num; |
| 2460 | } |
| 2461 | } |
| 2462 | |
| 2463 | return item; |
| 2464 | } |
| 2465 | |
| 2466 | CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) |
| 2467 | { |
no test coverage detected
searching dependent graphs…