| 2288 | } |
| 2289 | |
| 2290 | CJSON_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 | |
| 2316 | CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) |
| 2317 | { |
no test coverage detected