From: Stefan Krah Date: Wed, 18 Apr 2012 15:48:34 +0000 (+0200) Subject: The previous code is correct, but hard to verify: The libmpdec documentation X-Git-Tag: v3.3.0a3~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=140893cbaa086e0bcef9c47c11eaddd3015089c5;p=python The previous code is correct, but hard to verify: The libmpdec documentation rightfully states that an mpd_t with a coefficient flagged as MPD_CONST_DATA must not be in the position of the result operand. In this particular case several assumptions guarantee that a resize will never occur in all possible code paths, which was the reason for using MPD_CONST_DATA and saving an instruction by omitting the initialization of tmp.alloc. For readability, tmp is now flagged as MPD_STATIC_DATA and tmp.alloc is initialized. --- diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c index 844f2387a1..f0ebca887e 100644 --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -1280,7 +1280,8 @@ _mpd_qget_uint(int use_sign, const mpd_t *a, uint32_t *status) /* At this point a->digits+a->exp <= MPD_RDIGITS+1, * so the shift fits. */ tmp.data = tmp_data; - tmp.flags = MPD_STATIC|MPD_CONST_DATA; + tmp.flags = MPD_STATIC|MPD_STATIC_DATA; + tmp.alloc = 2; mpd_qsshiftr(&tmp, a, -a->exp); tmp.exp = 0; a = &tmp;