Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 140893c

Browse files
author
Stefan Krah
committed
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.
1 parent 447f0cc commit 140893c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Modules/_decimal/libmpdec/mpdecimal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@ _mpd_qget_uint(int use_sign, const mpd_t *a, uint32_t *status)
12801280
/* At this point a->digits+a->exp <= MPD_RDIGITS+1,
12811281
* so the shift fits. */
12821282
tmp.data = tmp_data;
1283-
tmp.flags = MPD_STATIC|MPD_CONST_DATA;
1283+
tmp.flags = MPD_STATIC|MPD_STATIC_DATA;
1284+
tmp.alloc = 2;
12841285
mpd_qsshiftr(&tmp, a, -a->exp);
12851286
tmp.exp = 0;
12861287
a = &tmp;

0 commit comments

Comments
 (0)