Skip to content

Commit d037ad7

Browse files
committed
holder_construct: unsigned char -> bool
1 parent 66e654a commit d037ad7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/pybind11/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
350350
space += t->holder_size_in_ptrs; // holder instance
351351
}
352352
size_t flags_at = space;
353-
space += size_in_ptrs(n_types); // holder constructed flags
353+
space += size_in_ptrs(n_types * sizeof(bool)); // holder constructed flags
354354

355355
// Allocate space for flags, values, and holders, and initialize it to 0 (flags and values,
356356
// in particular, need to be 0). Use Python's memory allocation functions: in Python 3.6
@@ -365,7 +365,7 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
365365
if (!nonsimple.values_and_holders) throw std::bad_alloc();
366366
std::memset(nonsimple.values_and_holders, 0, space * sizeof(void *));
367367
#endif
368-
nonsimple.holder_constructed = reinterpret_cast<unsigned char *>(&nonsimple.values_and_holders[flags_at]);
368+
nonsimple.holder_constructed = reinterpret_cast<bool *>(&nonsimple.values_and_holders[flags_at]);
369369
}
370370
owned = true;
371371
}

include/pybind11/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ struct instance {
375375
void *simple_value_holder[1 + instance_simple_holder_in_ptrs()];
376376
struct {
377377
void **values_and_holders;
378-
unsigned char *holder_constructed;
378+
bool *holder_constructed;
379379
} nonsimple;
380380
};
381381
/// Weak references (needed for keep alive):
@@ -398,7 +398,7 @@ struct instance {
398398
* pointer to allocated space of the required space to hold a a sequence of value pointers and
399399
* holders followed by a set of holder-constructed flags (1 byte each), i.e.
400400
* [val1*][holder1][val2*][holder2]...[bb...] where each [block] is rounded up to a multiple of
401-
* `sizeof(void *)`. `nonsimple.holders_constructed` is, for convenience, a pointer to the
401+
* `sizeof(void *)`. `nonsimple.holder_constructed` is, for convenience, a pointer to the
402402
* beginning of the [bb...] block (but not independently allocated).
403403
*/
404404
bool simple_layout : 1;

0 commit comments

Comments
 (0)