mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
bptr.h: size optimizations.
This commit is contained in:
parent
9579a51a8b
commit
dc56c4e530
22
src/bptr.h
22
src/bptr.h
|
@ -77,19 +77,31 @@ public:
|
|||
|
||||
private:
|
||||
void checkNULL() const {
|
||||
if (!ptr_)
|
||||
if __acc_very_unlikely(!ptr_)
|
||||
throwCantUnpack("unexpected NULL pointer; take care!");
|
||||
}
|
||||
void checkRange(size_t extra=0) const {
|
||||
void checkRange() const {
|
||||
size_t off = (const char *) ptr_ - (const char *) base_;
|
||||
if (off > size_ || off + extra > size_)
|
||||
if __acc_very_unlikely(off > size_)
|
||||
throwCantUnpack("pointer out of range; take care!");
|
||||
}
|
||||
void checkStrict(size_t extra=0) const {
|
||||
void checkRange(size_t extra) const {
|
||||
size_t off = (const char *) ptr_ - (const char *) base_;
|
||||
if __acc_very_unlikely(off > size_ || off + extra > size_)
|
||||
throwCantUnpack("pointer out of range; take care!");
|
||||
}
|
||||
void checkStrict() const {
|
||||
checkNULL();
|
||||
checkRange();
|
||||
}
|
||||
void checkStrict(size_t extra) const {
|
||||
checkNULL();
|
||||
checkRange(extra);
|
||||
}
|
||||
void check(size_t extra=0) const {
|
||||
void check() const {
|
||||
if (ptr_) checkRange();
|
||||
}
|
||||
void check(size_t extra) const {
|
||||
if (ptr_) checkRange(extra);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user