MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cJSON_CreateNumber

Function cJSON_CreateNumber

lib/cJSON.c:2156–2180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2154}
2155
2156cJSON *cJSON_CreateNumber(double num)
2157{
2158 cJSON *item = cJSON_New_Item();
2159 if(item)
2160 {
2161 item->type = cJSON_Number;
2162 item->valuedouble = num;
2163
2164 /* use saturation in case of overflow */
2165 if (num >= INT_MAX)
2166 {
2167 item->valueint = INT_MAX;
2168 }
2169 else if (num <= INT_MIN)
2170 {
2171 item->valueint = INT_MIN;
2172 }
2173 else
2174 {
2175 item->valueint = (int)num;
2176 }
2177 }
2178
2179 return item;
2180}
2181
2182cJSON *cJSON_CreateString(const char *string)
2183{

Callers 4

cJSON_CreateIntArrayFunction · 0.70
cJSON_CreateFloatArrayFunction · 0.70
cJSON_CreateDoubleArrayFunction · 0.70
payload_add_paramsFunction · 0.50

Calls 1

cJSON_New_ItemFunction · 0.70

Tested by

no test coverage detected