sc/source/core/data/bcaslot.cxx |   41 ++++++++++++++++++++++++----------------
 sc/source/core/inc/bcaslot.hxx  |    5 ++--
 tsan-suppress.txt               |    1 
 3 files changed, 29 insertions(+), 18 deletions(-)

New commits:
commit 9fa65519ab203500928cd63560b35daedb6e5ed9
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 2 09:40:30 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Sep 2 10:58:42 2022 +0200

    add more tsan supress
    
    for new glib functions that show up
    
    Change-Id: I43929d043e2fd1c72c262f50e6aaa62a557c02b4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139252
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/tsan-suppress.txt b/tsan-suppress.txt
index 9c86e10f90cd..33452dac40cf 100644
--- a/tsan-suppress.txt
+++ b/tsan-suppress.txt
@@ -61,3 +61,4 @@ race:g_source_unref_internal
 race:g_task_finalize
 race:g_socket_send_message_with_timeout
 race:g_idle_source_new
+race:g_slice_alloc0
commit ac7be5bec77ff65969f923c417d88454a4e216ef
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Sep 1 21:56:38 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Sep 2 10:58:27 2022 +0200

    no need to use unique_ptr for this map in TableSlotsMap
    
    map is already a node based data structure, so the values will stay
    in the same place in memory
    
    Change-Id: Ic1d3a671eda09e5fa6def30393e344d57a54d3c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139238
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 09493963469c..a39d5b4812b4 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -555,10 +555,17 @@ ScBroadcastAreaSlotMachine::TableSlots::TableSlots(SCSIZE 
nBcaSlots)
     memset( ppSlots.get(), 0 , sizeof( ScBroadcastAreaSlot* ) * nBcaSlots );
 }
 
+ScBroadcastAreaSlotMachine::TableSlots::TableSlots(TableSlots&& rOther) 
noexcept
+    : mnBcaSlots(rOther.mnBcaSlots)
+    , ppSlots( std::move(rOther.ppSlots) )
+{
+}
+
 ScBroadcastAreaSlotMachine::TableSlots::~TableSlots()
 {
-    for ( ScBroadcastAreaSlot** pp = ppSlots.get() + mnBcaSlots; --pp >= 
ppSlots.get(); /* nothing */ )
-        delete *pp;
+    if (ppSlots)
+        for ( ScBroadcastAreaSlot** pp = ppSlots.get() + mnBcaSlots; --pp >= 
ppSlots.get(); /* nothing */ )
+            delete *pp;
 }
 
 ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine(
@@ -789,8 +796,9 @@ void ScBroadcastAreaSlotMachine::StartListeningArea(
         {
             TableSlotsMap::iterator iTab( aTableSlotsMap.find( nTab));
             if (iTab == aTableSlotsMap.end())
-                iTab = aTableSlotsMap.emplace(nTab, 
std::make_unique<TableSlots>(mnBcaSlots)).first;
-            ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+                iTab = aTableSlotsMap.emplace( std::piecewise_construct,
+                        std::forward_as_tuple(nTab), 
std::forward_as_tuple(mnBcaSlots) ).first;
+            ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
             SCSIZE nStart, nEnd, nRowBreak;
             ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
             SCSIZE nOff = nStart;
@@ -837,7 +845,7 @@ void ScBroadcastAreaSlotMachine::EndListeningArea(
         for (TableSlotsMap::iterator iTab( aTableSlotsMap.lower_bound( 
rRange.aStart.Tab()));
                 iTab != aTableSlotsMap.end() && (*iTab).first <= nEndTab; 
++iTab)
         {
-            ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+            ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
             SCSIZE nStart, nEnd, nRowBreak;
             ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
             SCSIZE nOff = nStart;
@@ -875,7 +883,7 @@ bool ScBroadcastAreaSlotMachine::AreaBroadcast( const 
ScRange& rRange, SfxHintId
     for (TableSlotsMap::iterator iTab( aTableSlotsMap.lower_bound( 
rRange.aStart.Tab()));
             iTab != aTableSlotsMap.end() && (*iTab).first <= nEndTab; ++iTab)
     {
-        ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+        ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
         SCSIZE nStart, nEnd, nRowBreak;
         ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
         SCSIZE nOff = nStart;
@@ -913,7 +921,7 @@ bool ScBroadcastAreaSlotMachine::AreaBroadcast( const 
ScHint& rHint ) const
         ScRange broadcastRange( rAddress,
             ScAddress( rAddress.Col(), rAddress.Row() + rHint.GetRowCount() - 
1, rAddress.Tab()));
         bool bBroadcasted = false;
-        ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+        ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
         SCSIZE nStart, nEnd, nRowBreak;
         ComputeAreaPoints( broadcastRange, nStart, nEnd, nRowBreak );
         SCSIZE nOff = nStart;
@@ -936,7 +944,7 @@ void ScBroadcastAreaSlotMachine::DelBroadcastAreasInRange(
     for (TableSlotsMap::iterator iTab( aTableSlotsMap.lower_bound( 
rRange.aStart.Tab()));
             iTab != aTableSlotsMap.end() && (*iTab).first <= nEndTab; ++iTab)
     {
-        ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+        ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
         SCSIZE nStart, nEnd, nRowBreak;
         ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
         SCSIZE nOff = nStart;
@@ -975,7 +983,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
     for (TableSlotsMap::iterator iTab( aTableSlotsMap.lower_bound( 
rRange.aStart.Tab()));
             iTab != aTableSlotsMap.end() && (*iTab).first <= nEndTab; ++iTab)
     {
-        ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+        ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
         SCSIZE nStart, nEnd, nRowBreak;
         ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
         SCSIZE nOff = nStart;
@@ -1020,7 +1028,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
                 OSL_FAIL( "UpdateBroadcastAreas: Where's the TableSlot?!?");
                 continue;   // for
             }
-            ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+            ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
             SCSIZE nStart, nEnd, nRowBreak;
             ComputeAreaPoints( aRange, nStart, nEnd, nRowBreak );
             SCSIZE nOff = nStart;
@@ -1052,7 +1060,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
             while (iTab != aTableSlotsMap.end())
             {
                 SCTAB nTab = (*iTab).first + nDz;
-                aTableSlotsMap[nTab] = std::move((*iTab).second);
+                aTableSlotsMap.emplace(nTab, std::move((*iTab).second));
                 iTab = aTableSlotsMap.erase(iTab);
             }
         }
@@ -1069,14 +1077,14 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
                 while (iTab != iStop)
                 {
                     SCTAB nTab = (*iTab).first + nDz;
-                    aTableSlotsMap[nTab] = std::move((*iTab).second);
+                    aTableSlotsMap.emplace(nTab, std::move((*iTab).second));
                     aTableSlotsMap.erase( iTab--);
                 }
                 // Shift the very first, iTab==iStop in this case.
                 if (bStopIsBegin)
                 {
                     SCTAB nTab = (*iTab).first + nDz;
-                    aTableSlotsMap[nTab] = std::move((*iTab).second);
+                    aTableSlotsMap.emplace(nTab, std::move((*iTab).second));
                     aTableSlotsMap.erase( iStop);
                 }
             }
@@ -1111,8 +1119,9 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
         {
             TableSlotsMap::iterator iTab( aTableSlotsMap.find( nTab));
             if (iTab == aTableSlotsMap.end())
-                iTab = aTableSlotsMap.emplace(nTab, 
std::make_unique<TableSlots>(mnBcaSlots)).first;
-            ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+                iTab = aTableSlotsMap.emplace( std::piecewise_construct,
+                        std::forward_as_tuple(nTab), 
std::forward_as_tuple(mnBcaSlots) ).first;
+            ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
             SCSIZE nStart, nEnd, nRowBreak;
             ComputeAreaPoints( aRange, nStart, nEnd, nRowBreak );
             SCSIZE nOff = nStart;
@@ -1256,7 +1265,7 @@ std::vector<sc::AreaListener> 
ScBroadcastAreaSlotMachine::GetAllListeners(
     for (TableSlotsMap::const_iterator iTab( aTableSlotsMap.lower_bound( 
rRange.aStart.Tab()));
             iTab != aTableSlotsMap.end() && (*iTab).first <= nEndTab; ++iTab)
     {
-        ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+        ScBroadcastAreaSlot** ppSlots = (*iTab).second.getSlots();
         SCSIZE nStart, nEnd, nRowBreak;
         ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak );
         SCSIZE nOff = nStart;
diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx
index c77a1173c7e3..4e1173596840 100644
--- a/sc/source/core/inc/bcaslot.hxx
+++ b/sc/source/core/inc/bcaslot.hxx
@@ -263,8 +263,9 @@ private:
     {
     public:
                                         TableSlots(SCSIZE nBcaSlots);
+                                        TableSlots(TableSlots&&) noexcept;
                                         ~TableSlots();
-        ScBroadcastAreaSlot**    getSlots() { return ppSlots.get(); }
+        ScBroadcastAreaSlot**    getSlots() const { return ppSlots.get(); }
 
     private:
         SCSIZE                                    mnBcaSlots;
@@ -274,7 +275,7 @@ private:
         TableSlots& operator=( const TableSlots& ) = delete;
     };
 
-    typedef ::std::map< SCTAB, std::unique_ptr<TableSlots> > TableSlotsMap;
+    typedef ::std::map< SCTAB, TableSlots > TableSlotsMap;
 
     typedef ::std::vector< ::std::pair< ScBroadcastAreaSlot*, 
ScBroadcastAreas::iterator > > AreasToBeErased;
 

Reply via email to