aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-10-17 09:37:32 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-10-31 15:10:52 +0200
commite34a232d5c175b9504c6713eb9dc7ed373456801 (patch)
tree0acf5f141c292892bc12fb132e1ed61b7f030f06 /src/qml/memory
parent4c930c2ce51b3a3fe3c51d748c85bdafde940227 (diff)
Avoid -Wshorten-64-to-32 warnings in a few places
...by explictily casting to int. Add a few comments explaining why we can get at most INT_MAX many elements, and add Q_ASSERTS to check that the assumptions actually hold. Task-number: QTBUG-105055 Change-Id: I1769318a9c04b51efe45fe0cae9fc0d93cfec45e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4mmdefs_p.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h
index 395f0870e4..c873bfd5f8 100644
--- a/src/qml/memory/qv4mmdefs_p.h
+++ b/src/qml/memory/qv4mmdefs_p.h
@@ -178,17 +178,17 @@ struct HeapItem {
bool isGray() const {
Chunk *c = chunk();
- uint index = this - c->realBase();
+ std::ptrdiff_t index = this - c->realBase();
return Chunk::testBit(c->grayBitmap, index);
}
bool isBlack() const {
Chunk *c = chunk();
- uint index = this - c->realBase();
+ std::ptrdiff_t index = this - c->realBase();
return Chunk::testBit(c->blackBitmap, index);
}
bool isInUse() const {
Chunk *c = chunk();
- uint index = this - c->realBase();
+ std::ptrdiff_t index = this - c->realBase();
return Chunk::testBit(c->objectBitmap, index);
}
@@ -207,10 +207,10 @@ struct HeapItem {
// Doesn't report correctly for huge items
size_t size() const {
Chunk *c = chunk();
- uint index = this - c->realBase();
+ std::ptrdiff_t index = this - c->realBase();
Q_ASSERT(Chunk::testBit(c->objectBitmap, index));
// ### optimize me
- uint end = index + 1;
+ std::ptrdiff_t end = index + 1;
while (end < Chunk::NumSlots && Chunk::testBit(c->extendsBitmap, end))
++end;
return (end - index)*sizeof(HeapItem);