mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
62d2cadb62
extra/yassl/FLOSS-EXCEPTIONS: Import patch yassl.diff extra/yassl/README: Import patch yassl.diff extra/yassl/examples/client/client.cpp: Import patch yassl.diff extra/yassl/examples/echoclient/echoclient.cpp: Import patch yassl.diff extra/yassl/examples/echoserver/echoserver.cpp: Import patch yassl.diff extra/yassl/examples/server/server.cpp: Import patch yassl.diff extra/yassl/include/buffer.hpp: Import patch yassl.diff extra/yassl/include/cert_wrapper.hpp: Import patch yassl.diff extra/yassl/include/crypto_wrapper.hpp: Import patch yassl.diff extra/yassl/include/factory.hpp: Import patch yassl.diff extra/yassl/include/openssl/ssl.h: Import patch yassl.diff extra/yassl/include/socket_wrapper.hpp: Import patch yassl.diff extra/yassl/include/yassl_error.hpp: Import patch yassl.diff extra/yassl/include/yassl_imp.hpp: Import patch yassl.diff extra/yassl/include/yassl_int.hpp: Import patch yassl.diff extra/yassl/include/yassl_types.hpp: Import patch yassl.diff extra/yassl/src/cert_wrapper.cpp: Import patch yassl.diff extra/yassl/src/crypto_wrapper.cpp: Import patch yassl.diff extra/yassl/src/handshake.cpp: Import patch yassl.diff extra/yassl/src/socket_wrapper.cpp: Import patch yassl.diff extra/yassl/src/ssl.cpp: Import patch yassl.diff extra/yassl/src/template_instnt.cpp: Import patch yassl.diff extra/yassl/src/yassl.cpp: Import patch yassl.diff extra/yassl/src/yassl_error.cpp: Import patch yassl.diff extra/yassl/src/yassl_imp.cpp: Import patch yassl.diff extra/yassl/src/yassl_int.cpp: Import patch yassl.diff extra/yassl/taocrypt/COPYING: Import patch yassl.diff extra/yassl/taocrypt/INSTALL: Import patch yassl.diff extra/yassl/taocrypt/README: Import patch yassl.diff extra/yassl/taocrypt/include/asn.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/block.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/blowfish.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/error.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/file.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/integer.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/misc.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/pwdbased.hpp: Import patch yassl.diff extra/yassl/taocrypt/include/twofish.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/algorithm.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/helpers.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/list.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/memory.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/memory_array.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/pair.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/stdexcept.hpp: Import patch yassl.diff extra/yassl/taocrypt/mySTL/vector.hpp: Import patch yassl.diff extra/yassl/taocrypt/src/algebra.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/asn.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/blowfish.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/des.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/dh.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/integer.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/md4.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/md5.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/random.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/ripemd.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/sha.cpp: Import patch yassl.diff extra/yassl/taocrypt/src/template_instnt.cpp: Import patch yassl.diff extra/yassl/testsuite/test.hpp: Import patch yassl.diff BitKeeper/deleted/.del-algorithm.hpp: Delete: extra/yassl/mySTL/algorithm.hpp BitKeeper/deleted/.del-helpers.hpp: Delete: extra/yassl/mySTL/helpers.hpp BitKeeper/deleted/.del-list.hpp: Delete: extra/yassl/mySTL/list.hpp BitKeeper/deleted/.del-pair.hpp: Delete: extra/yassl/mySTL/pair.hpp BitKeeper/deleted/.del-stdexcept.hpp: Delete: extra/yassl/mySTL/stdexcept.hpp BitKeeper/deleted/.del-vector.hpp: Delete: extra/yassl/mySTL/vector.hpp BitKeeper/deleted/.del-memory.hpp: Delete: extra/yassl/mySTL/memory.hpp extra/yassl/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/src/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/taocrypt/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/taocrypt/benchmark/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/taocrypt/src/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/taocrypt/src/misc.cpp: Remove the functions CRYPTO_lock and CRYPTO_add_lock as they would collide with OpenSSL functions extra/yassl/taocrypt/test/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt extra/yassl/testsuite/Makefile.am: mySTL directory has moved from yassl/ to yassl/taocrypt
142 lines
2.9 KiB
C++
142 lines
2.9 KiB
C++
/* mySTL memory_array.hpp
|
|
*
|
|
* Copyright (C) 2003 Sawtooth Consulting Ltd.
|
|
*
|
|
* This file is part of yaSSL.
|
|
*
|
|
* yaSSL is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* There are special exceptions to the terms and conditions of the GPL as it
|
|
* is applied to yaSSL. View the full text of the exception in the file
|
|
* FLOSS-EXCEPTIONS in the directory of this software distribution.
|
|
*
|
|
* yaSSL is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
*/
|
|
|
|
|
|
/* mySTL memory_arry implements auto_array
|
|
*
|
|
*/
|
|
|
|
#ifndef mySTL_MEMORY_ARRAY_HPP
|
|
#define mySTL_MEMORY_ARRAY_HPP
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
// disable operator-> warning for builtins
|
|
#pragma warning(disable:4284)
|
|
#endif
|
|
|
|
|
|
namespace mySTL {
|
|
|
|
|
|
template<typename T>
|
|
struct auto_array_ref {
|
|
T* ptr_;
|
|
explicit auto_array_ref(T* p) : ptr_(p) {}
|
|
};
|
|
|
|
|
|
template<typename T>
|
|
class auto_array {
|
|
T* ptr_;
|
|
|
|
void Destroy()
|
|
{
|
|
#ifdef YASSL_LIB
|
|
yaSSL::ysArrayDelete(ptr_);
|
|
#else
|
|
TaoCrypt::tcArrayDelete(ptr_);
|
|
#endif
|
|
}
|
|
public:
|
|
explicit auto_array(T* p = 0) : ptr_(p) {}
|
|
|
|
~auto_array()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
|
|
auto_array(auto_array& other) : ptr_(other.release()) {}
|
|
|
|
auto_array& operator=(auto_array& that)
|
|
{
|
|
if (this != &that) {
|
|
Destroy();
|
|
ptr_ = that.release();
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
|
|
T* operator->() const
|
|
{
|
|
return ptr_;
|
|
}
|
|
|
|
T& operator*() const
|
|
{
|
|
return *ptr_;
|
|
}
|
|
|
|
T* get() const
|
|
{
|
|
return ptr_;
|
|
}
|
|
|
|
T* release()
|
|
{
|
|
T* tmp = ptr_;
|
|
ptr_ = 0;
|
|
return tmp;
|
|
}
|
|
|
|
void reset(T* p = 0)
|
|
{
|
|
if (ptr_ != p) {
|
|
Destroy();
|
|
ptr_ = p;
|
|
}
|
|
}
|
|
|
|
// auto_array_ref conversions
|
|
auto_array(auto_array_ref<T> ref) : ptr_(ref.ptr_) {}
|
|
|
|
auto_array& operator=(auto_array_ref<T> ref)
|
|
{
|
|
if (this->ptr_ != ref.ptr_) {
|
|
Destroy();
|
|
ptr_ = ref.ptr_;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
template<typename T2>
|
|
operator auto_array<T2>()
|
|
{
|
|
return auto_array<T2>(this->release());
|
|
}
|
|
|
|
template<typename T2>
|
|
operator auto_array_ref<T2>()
|
|
{
|
|
return auto_array_ref<T2>(this->release());
|
|
}
|
|
};
|
|
|
|
|
|
} // namespace mySTL
|
|
|
|
#endif // mySTL_MEMORY_ARRAY_HPP
|