@@ -71,18 +71,6 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
71
71
Py_DECREF (self );
72
72
return NULL ;
73
73
}
74
-
75
- #ifndef MS_WIN32
76
- /* if we have a packed bitfield, calculate the minimum number of bytes we
77
- need to fit it. otherwise use the specified size. */
78
- if (pack && bitsize ) {
79
- size = (bitsize - 1 ) / 8 + 1 ;
80
- } else
81
- #endif
82
- size = dict -> size ;
83
-
84
- proto = desc ;
85
-
86
74
if (bitsize /* this is a bitfield request */
87
75
&& * pfield_size /* we have a bitfield open */
88
76
#ifdef MS_WIN32
@@ -99,26 +87,25 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
99
87
} else if (bitsize /* this is a bitfield request */
100
88
&& * pfield_size /* we have a bitfield open */
101
89
&& dict -> size * 8 >= * pfield_size
102
- /* if this is a packed bitfield, always expand it.
103
- otherwise calculate if we need to expand it. */
104
- && (((* pbitofs + bitsize ) <= dict -> size * 8 ) || pack )) {
90
+ && (* pbitofs + bitsize ) <= dict -> size * 8 ) {
105
91
/* expand bit field */
106
92
fieldtype = EXPAND_BITFIELD ;
107
93
#endif
108
94
} else if (bitsize ) {
109
95
/* start new bitfield */
110
96
fieldtype = NEW_BITFIELD ;
111
97
* pbitofs = 0 ;
112
- /* use our calculated size (size) instead of type size (dict->size),
113
- which can be different for packed bitfields */
114
- * pfield_size = size * 8 ;
98
+ * pfield_size = dict -> size * 8 ;
115
99
} else {
116
100
/* not a bit field */
117
101
fieldtype = NO_BITFIELD ;
118
102
* pbitofs = 0 ;
119
103
* pfield_size = 0 ;
120
104
}
121
105
106
+ size = dict -> size ;
107
+ proto = desc ;
108
+
122
109
/* Field descriptors for 'c_char * n' are be scpecial cased to
123
110
return a Python string instead of an Array object instance...
124
111
*/
@@ -183,16 +170,10 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
183
170
break ;
184
171
185
172
case EXPAND_BITFIELD :
186
- /* increase the size if it is a packed bitfield.
187
- EXPAND_BITFIELD should not be selected for non-packed fields if the
188
- current size isn't already enough. */
189
- if (pack )
190
- size = (* pbitofs + bitsize - 1 ) / 8 + 1 ;
191
-
192
- * poffset += size - * pfield_size /8 ;
193
- * psize += size - * pfield_size /8 ;
173
+ * poffset += dict -> size - * pfield_size /8 ;
174
+ * psize += dict -> size - * pfield_size /8 ;
194
175
195
- * pfield_size = size * 8 ;
176
+ * pfield_size = dict -> size * 8 ;
196
177
197
178
if (big_endian )
198
179
self -> size = (bitsize << 16 ) + * pfield_size - * pbitofs - bitsize ;
0 commit comments