Lines Matching full:result
156 mpd_t *result; in mpd_qnew_size() local
160 result = mpd_alloc(1, sizeof *result); in mpd_qnew_size()
161 if (result == NULL) { in mpd_qnew_size()
165 result->data = mpd_alloc(nwords, sizeof *result->data); in mpd_qnew_size()
166 if (result->data == NULL) { in mpd_qnew_size()
167 mpd_free(result); in mpd_qnew_size()
171 result->flags = 0; in mpd_qnew_size()
172 result->exp = 0; in mpd_qnew_size()
173 result->digits = 0; in mpd_qnew_size()
174 result->len = 0; in mpd_qnew_size()
175 result->alloc = nwords; in mpd_qnew_size()
177 return result; in mpd_qnew_size()
193 mpd_t *result; in mpd_new() local
195 result = mpd_qnew(); in mpd_new()
196 if (result == NULL) { in mpd_new()
199 return result; in mpd_new()
203 * Input: 'result' is a static mpd_t with a static coefficient.
204 * Assumption: 'nwords' >= result->alloc.
207 * existing data. If successful, the value of 'result' is unchanged.
208 * Otherwise, set 'result' to NaN and update 'status' with MPD_Malloc_error.
211 mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status) in mpd_switch_to_dyn() argument
213 mpd_uint_t *p = result->data; in mpd_switch_to_dyn()
215 assert(nwords >= result->alloc); in mpd_switch_to_dyn()
217 result->data = mpd_alloc(nwords, sizeof *result->data); in mpd_switch_to_dyn()
218 if (result->data == NULL) { in mpd_switch_to_dyn()
219 result->data = p; in mpd_switch_to_dyn()
220 mpd_set_qnan(result); in mpd_switch_to_dyn()
221 mpd_set_positive(result); in mpd_switch_to_dyn()
222 result->exp = result->digits = result->len = 0; in mpd_switch_to_dyn()
227 memcpy(result->data, p, result->alloc * (sizeof *result->data)); in mpd_switch_to_dyn()
228 result->alloc = nwords; in mpd_switch_to_dyn()
229 mpd_set_dynamic_data(result); in mpd_switch_to_dyn()
234 * Input: 'result' is a static mpd_t with a static coefficient.
237 * malloc fails, set 'result' to NaN and update 'status' with MPD_Malloc_error.
240 mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t nwords, uint32_t *status) in mpd_switch_to_dyn_zero() argument
242 mpd_uint_t *p = result->data; in mpd_switch_to_dyn_zero()
244 result->data = mpd_calloc(nwords, sizeof *result->data); in mpd_switch_to_dyn_zero()
245 if (result->data == NULL) { in mpd_switch_to_dyn_zero()
246 result->data = p; in mpd_switch_to_dyn_zero()
247 mpd_set_qnan(result); in mpd_switch_to_dyn_zero()
248 mpd_set_positive(result); in mpd_switch_to_dyn_zero()
249 result->exp = result->digits = result->len = 0; in mpd_switch_to_dyn_zero()
254 result->alloc = nwords; in mpd_switch_to_dyn_zero()
255 mpd_set_dynamic_data(result); in mpd_switch_to_dyn_zero()
261 * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
263 * Case nwords > result->alloc:
265 * 'result' has a larger coefficient but the same value. Return 1.
267 * Set 'result' to NaN, update status with MPD_Malloc_error and return 0.
268 * Case nwords < result->alloc:
270 * 'result' has a smaller coefficient. result->len is undefined. Return 1.
272 * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
275 mpd_realloc_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status) in mpd_realloc_dyn() argument
279 result->data = mpd_realloc(result->data, nwords, sizeof *result->data, &err); in mpd_realloc_dyn()
281 result->alloc = nwords; in mpd_realloc_dyn()
283 else if (nwords > result->alloc) { in mpd_realloc_dyn()
284 mpd_set_qnan(result); in mpd_realloc_dyn()
285 mpd_set_positive(result); in mpd_realloc_dyn()
286 result->exp = result->digits = result->len = 0; in mpd_realloc_dyn()
295 * Input: 'result' is a static mpd_t with a static coefficient.
296 * Assumption: 'nwords' >= result->alloc.
301 * On failure the value of 'result' is unchanged.
304 mpd_switch_to_dyn_cxx(mpd_t *result, mpd_ssize_t nwords) in mpd_switch_to_dyn_cxx() argument
306 assert(nwords >= result->alloc); in mpd_switch_to_dyn_cxx()
308 mpd_uint_t *data = mpd_alloc(nwords, sizeof *result->data); in mpd_switch_to_dyn_cxx()
313 memcpy(data, result->data, result->alloc * (sizeof *result->data)); in mpd_switch_to_dyn_cxx()
314 result->data = data; in mpd_switch_to_dyn_cxx()
315 result->alloc = nwords; in mpd_switch_to_dyn_cxx()
316 mpd_set_dynamic_data(result); in mpd_switch_to_dyn_cxx()
321 * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
323 * Case nwords > result->alloc:
325 * 'result' has a larger coefficient but the same value. Return 1.
327 * 'result' has a the same coefficient. Return 0.
328 * Case nwords < result->alloc:
330 * 'result' has a smaller coefficient. result->len is undefined. Return 1.
332 * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
335 mpd_realloc_dyn_cxx(mpd_t *result, mpd_ssize_t nwords) in mpd_realloc_dyn_cxx() argument
339 mpd_uint_t *p = mpd_realloc(result->data, nwords, sizeof *result->data, &err); in mpd_realloc_dyn_cxx()
341 result->data = p; in mpd_realloc_dyn_cxx()
342 result->alloc = nwords; in mpd_realloc_dyn_cxx()
344 else if (nwords > result->alloc) { in mpd_realloc_dyn_cxx()