From 2138a3fd2c8599d1d5ce66a423e86f61ba4dfe69 Mon Sep 17 00:00:00 2001 From: Katy Feng Date: Thu, 5 Oct 2023 10:35:26 -0700 Subject: [PATCH] Remove Glib usage from stringxx/ubstr_t. Replace Glib::RefPtr with std::shared_ptr. --- .../plugins/dndcp/stringxx/ubstr_t.hh | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh b/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh index b4726e22a..9713ee8ff 100644 --- a/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh +++ b/open-vm-tools/services/plugins/dndcp/stringxx/ubstr_t.hh @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2008-2019,2021-2022 VMware, Inc. All rights reserved. + * Copyright (c) 2008-2019,2021-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -32,8 +32,7 @@ #include #include -#include // For GIOMM_*_VERSION -#include +#include #include "autoCPtr.hh" @@ -111,30 +110,10 @@ private: public: // Takes ownership of the input string. UTF8Data(char *utf8String = NULL) // IN/OUT: May be NULL - : mUTF8String(utf8String), - mRefCount(1) + : mUTF8String(utf8String) { } -#if GIOMM_MAJOR_VERSION >= 2 && GIOMM_MINOR_VERSION >= 68 - // Glib::RefPtr is now just a std::shared_ptr so no extras are needed -#else - // For Glib::RefPtr. - void reference() - { - ++mRefCount; - } - - // For Glib::RefPtr. - void unreference() - { - --mRefCount; - if (mRefCount == 0) { - delete this; - } - } -#endif - // Takes ownership of the input string. void Set(char *utf8String) // IN/OUT: May be NULL. { @@ -150,12 +129,6 @@ private: return mUTF8String; } -#if GIOMM_MAJOR_VERSION >= 2 && GIOMM_MINOR_VERSION >= 68 - public: -#else - private: - // Only destructible via unreference(). -#endif ~UTF8Data() { free(mUTF8String); @@ -163,7 +136,6 @@ private: private: char *mUTF8String; - unsigned int mRefCount; private: // Intentionally unimplemented. @@ -181,7 +153,7 @@ private: _bstr_t mBstr; // mUTF8 is allocated and initialized lazily. - mutable Glib::RefPtr mUTF8; + mutable std::shared_ptr mUTF8; }; @@ -265,7 +237,7 @@ ubstr_t::ubstr_t(const char *s) // IN: A UTF-8-encoded string. { if (s != NULL) { // Since we already have the UTF-8 version of the string, cache it now. - mUTF8 = Glib::RefPtr(new UTF8Data(Util_SafeStrdup(s))); + mUTF8 = std::shared_ptr(new UTF8Data(Util_SafeStrdup(s))); mBstr = AutoCPtr(Unicode_GetAllocUTF16(s), free).get(); } } @@ -310,7 +282,7 @@ ubstr_t::ubstr_t(const ubstr_t& s) // IN mUTF8(s.mUTF8) { if (static_cast(mBstr) != NULL && !mUTF8) { - mUTF8 = s.mUTF8 = Glib::RefPtr(new UTF8Data()); + mUTF8 = s.mUTF8 = std::shared_ptr(new UTF8Data()); } } @@ -839,7 +811,7 @@ ubstr_t::GetUTF8Cache() } if (!mUTF8) { - mUTF8 = Glib::RefPtr(new UTF8Data()); + mUTF8 = std::shared_ptr(new UTF8Data()); } if (mUTF8->Get() == NULL) { -- 2.47.3