[vbox-dev] Fix vector::data() methods and add vector::clear()
Andreas Löffler
andreas.loeffler at oracle.com
Tue Jan 3 08:54:51 GMT 2023
Hi Martin,
a happy new year to you, too! I've just committed the fixes -- thanks
again for your patch(es)!
--
Kind regards / Mit freundlichen Grüßen
******************************************************************
Andreas Löffler | VirtualBox Engineering
Principal Software Engineer | Oracle Virtualization
Oracle Global Services Germany GmbH
Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRB 246209
Geschäftsführer: Ralf Herrmann
Green Oracle <http://www.oracle.com/commitment>
<http://www.oracle.com/commitment%3e>; Oracle is committed to developing
practices and products that help protect the environment
On 28.12.22 15:04, Martin Fleisz via vbox-dev wrote:
> The patch below fixes a compilation issue when using vector::data() and
> adds a clear() method to the template.
>
> I'm submitting this patch under the MIT license.
>
> Best regards and a happy new year!
>
> Martin Fleisz
> Thincast Technologies GmbH
> Bahnhofplatz 7/3, 2340 Moedling, Austria
> http://www.thincast.com
>
>
> diff --git include/iprt/nocrt/vector include/iprt/nocrt/vector
> index 925f9e1ac18..e5ed2c4f4ce 100644
> --- include/iprt/nocrt/vector
> +++ include/iprt/nocrt/vector
> @@ -228,15 +228,7 @@ namespace std
>
> ~vector()
> {
> - size_type i = m_cItems;
> - while (i-- > 0)
> - {
> - m_Allocator.destroy(&m_paItems[i]);
> - m_cItems = i;
> - }
> - m_Allocator.deallocate(m_paItems, m_cAllocated);
> - m_paItems = NULL;
> - m_cAllocated = 0;
> + clear();
> }
>
>
> @@ -309,12 +301,12 @@ namespace std
>
> pointer data() RT_NOEXCEPT
> {
> - return m_paItem;
> + return m_paItems;
> }
>
> const_pointer data() const RT_NOEXCEPT
> {
> - return m_paItem;
> + return m_paItems;
> }
>
> /** @} */
> @@ -385,6 +377,19 @@ namespace std
> if (m_cItems > 0)
> m_cItems -= 1;
> }
> +
> + void clear() RT_NOEXCEPT
> + {
> + size_type i = m_cItems;
> + while (i-- > 0)
> + {
> + m_Allocator.destroy(&m_paItems[i]);
> + m_cItems = i;
> + }
> + m_Allocator.deallocate(m_paItems, m_cAllocated);
> + m_paItems = NULL;
> + m_cAllocated = 0;
> + }
> /** @} */
>
> };
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x46BCB4E5EE437BAD.asc
Type: application/pgp-keys
Size: 3143 bytes
Desc: OpenPGP public key
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20230103/d2ec7cf4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20230103/d2ec7cf4/attachment.sig>
More information about the vbox-dev
mailing list