PAGED bool reserve()

in rtl/inc/karray.h [150:188]


    PAGED bool reserve(size_t count)
    {
        if (m_bufferSize >= count)
            return true;

        if (count >= (ULONG)(-1))
            return false;

        size_t bytesNeeded;
        if (!NT_SUCCESS(RtlSIZETMult(sizeof(T), count, reinterpret_cast<SIZE_T*>(&bytesNeeded))))
            return false;

        T * p = (T*)ExAllocatePoolWithTag(PoolType, bytesNeeded, 'rrAK');
        if (!p)
            return false;

        if constexpr(__is_trivially_copyable(T))
        {
            memcpy(p, _p, m_numElements * sizeof(T));
        }
        else
        {
            for (ULONG i = 0; i < m_numElements; i++)
                new (wistd::addressof(p[i])) T(wistd::move(_p[i]));
        }

        if (_p)
        {
            for (ULONG i = 0; i < m_numElements; i++)
                _p[i].~T();

            ExFreePoolWithTag(_p, 'rrAK');
        }

        m_bufferSize = static_cast<ULONG>(count);
        _p = p;

        return true;
    }