mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibCrypto: Allow moving SignedBigInteger / UnsignedBigInteger
We defined copy operations but not move operations, so every existing move() resulted in a copy.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
cd73c70ad6
commit
8600c5149b
Notes:
github-actions[bot]
2025-07-21 13:23:41 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/8600c5149b9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5543 Reviewed-by: https://github.com/gmta ✅
@@ -55,6 +55,14 @@ UnsignedBigInteger::UnsignedBigInteger(UnsignedBigInteger const& other)
|
||||
MP_MUST(mp_init_copy(&m_mp, &other.m_mp));
|
||||
}
|
||||
|
||||
UnsignedBigInteger::UnsignedBigInteger(UnsignedBigInteger&& other)
|
||||
: m_mp(other.m_mp)
|
||||
, m_hash(other.m_hash)
|
||||
{
|
||||
other.m_mp = {};
|
||||
other.m_hash.clear();
|
||||
}
|
||||
|
||||
UnsignedBigInteger& UnsignedBigInteger::operator=(UnsignedBigInteger const& other)
|
||||
{
|
||||
if (this == &other)
|
||||
@@ -67,6 +75,21 @@ UnsignedBigInteger& UnsignedBigInteger::operator=(UnsignedBigInteger const& othe
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnsignedBigInteger& UnsignedBigInteger::operator=(UnsignedBigInteger&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
mp_clear(&m_mp);
|
||||
m_mp = other.m_mp;
|
||||
m_hash = other.m_hash;
|
||||
|
||||
other.m_mp = {};
|
||||
other.m_hash.clear();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
UnsignedBigInteger::UnsignedBigInteger()
|
||||
{
|
||||
MP_MUST(mp_init(&m_mp));
|
||||
|
||||
Reference in New Issue
Block a user