[Libreoffice-commits] core.git: 2 commits - idlc/inc idlc/source include/comphelper sd/inc sd/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 30 06:30:32 UTC 2018
idlc/inc/aststack.hxx | 7 +-
idlc/source/aststack.cxx | 65 +++++---------------------
include/comphelper/interfacecontainer2.hxx | 10 ----
sd/inc/helper/simplereferencecomponent.hxx | 23 ---------
sd/source/helper/simplereferencecomponent.cxx | 39 ---------------
5 files changed, 17 insertions(+), 127 deletions(-)
New commits:
commit cb2c7428f68d2c07f5e97ae4b42fee7c43e709a8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 29 12:34:52 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 30 08:30:17 2018 +0200
use std::vector in AstStack
instead of a hand-coded equivalent. Note that I can't use
std::unique_ptr, because the parsing code appears to just randomly leak
AstScope
Change-Id: Idc56dfe1f084db55c9d5a7558ac44ddab53b98e3
Reviewed-on: https://gerrit.libreoffice.org/59771
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/idlc/inc/aststack.hxx b/idlc/inc/aststack.hxx
index fa13d7affd92..b3f4cda695fd 100644
--- a/idlc/inc/aststack.hxx
+++ b/idlc/inc/aststack.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_IDLC_INC_ASTSTACK_HXX
#include <sal/types.h>
+#include <vector>
class AstScope;
@@ -29,7 +30,7 @@ public:
AstStack();
~AstStack();
- sal_uInt32 depth() const { return m_top;}
+ sal_uInt32 depth() const { return m_stack.size();}
AstScope* top();
AstScope* bottom();
AstScope* nextToTop();
@@ -39,9 +40,7 @@ public:
void clear();
private:
- AstScope** m_stack;
- sal_uInt32 m_size;
- sal_uInt32 m_top;
+ std::vector<AstScope*> m_stack;
};
#endif // INCLUDED_IDLC_INC_ASTSTACK_HXX
diff --git a/idlc/source/aststack.cxx b/idlc/source/aststack.cxx
index 464879794d53..6e01cdabf089 100644
--- a/idlc/source/aststack.cxx
+++ b/idlc/source/aststack.cxx
@@ -21,102 +21,65 @@
#include <aststack.hxx>
#include <astscope.hxx>
-#define STACKSIZE_INCREMENT 64
-
AstStack::AstStack()
- : m_stack(static_cast<AstScope**>(rtl_allocateZeroMemory(sizeof(AstScope*) * STACKSIZE_INCREMENT)))
- , m_size(STACKSIZE_INCREMENT)
- , m_top(0)
{
}
AstStack::~AstStack()
{
- for(sal_uInt32 i=0; i < m_top; i++)
- {
- if (m_stack[i])
- delete m_stack[i];
- }
-
- std::free(m_stack);
+ for (AstScope* p : m_stack)
+ delete p;
}
AstScope* AstStack::top()
{
- if (m_top < 1)
+ if (m_stack.empty())
return nullptr;
- return m_stack[m_top - 1];
+ return m_stack.back();
}
AstScope* AstStack::bottom()
{
- if (m_top == 0)
+ if (m_stack.empty())
return nullptr;
- return m_stack[0];
+ return m_stack.front();
}
AstScope* AstStack::nextToTop()
{
- AstScope *tmp, *retval;
-
- if (depth() < 2)
+ if (m_stack.size() < 2)
return nullptr;
- tmp = top(); // Save top
- pop(); // Pop it
- retval = top(); // Get next one down
- (void) push(tmp); // Push top back
- return retval; // Return next one down
+ return m_stack[m_stack.size() - 2];
}
AstScope* AstStack::topNonNull()
{
- for (sal_uInt32 i = m_top; i > 0; i--)
+ for (sal_uInt32 i = m_stack.size(); i > 0; i--)
{
if ( m_stack[i - 1] )
return m_stack[i - 1];
- }
+ }
return nullptr;
}
AstStack* AstStack::push(AstScope* pScope)
{
- AstScope **tmp;
-// AstDeclaration *pDecl = ScopeAsDecl(pScope);
- sal_uInt32 newSize;
- sal_uInt32 i;
-
- // Make sure there's space for one more
- if (m_size == m_top)
- {
- newSize = m_size;
- newSize += STACKSIZE_INCREMENT;
- tmp = static_cast<AstScope**>(rtl_allocateZeroMemory(sizeof(AstScope*) * newSize));
-
- for(i=0; i < m_size; i++)
- tmp[i] = m_stack[i];
-
- std::free(m_stack);
- m_stack = tmp;
- }
-
- // Insert new scope
- m_stack[m_top++] = pScope;
-
+ m_stack.push_back(pScope);
return this;
}
void AstStack::pop()
{
- if (m_top < 1)
+ if (m_stack.empty())
return;
- --m_top;
+ m_stack.pop_back();
}
void AstStack::clear()
{
- m_top = 0;
+ m_stack.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e040d8defb774255e083825863641493f4c7d9ff
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 29 09:14:35 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 30 08:30:07 2018 +0200
don't declare allocation operators for internal code
since they just call into malloc/free now, we can ignore them. Should
have some nice side-effects like letting the compiler allocate
temporaries on the stack.
Change-Id: I2500abe19acf9b5bcc676604393c498d4e0dce58
Reviewed-on: https://gerrit.libreoffice.org/59658
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/comphelper/interfacecontainer2.hxx b/include/comphelper/interfacecontainer2.hxx
index f0f79c3033df..60bf7e74a1db 100644
--- a/include/comphelper/interfacecontainer2.hxx
+++ b/include/comphelper/interfacecontainer2.hxx
@@ -125,16 +125,6 @@ private:
class COMPHELPER_DLLPUBLIC OInterfaceContainerHelper2
{
public:
- // these are here to force memory de/allocation to sal lib.
- static void * operator new( size_t nSize )
- { return ::rtl_allocateMemory( nSize ); }
- static void operator delete( void * pMem )
- { ::rtl_freeMemory( pMem ); }
- static void * operator new( size_t, void * pMem )
- { return pMem; }
- static void operator delete( void *, void * )
- {}
-
/**
Create an interface container.
diff --git a/sd/inc/helper/simplereferencecomponent.hxx b/sd/inc/helper/simplereferencecomponent.hxx
index 64e894a4deef..bfe1c391535a 100644
--- a/sd/inc/helper/simplereferencecomponent.hxx
+++ b/sd/inc/helper/simplereferencecomponent.hxx
@@ -51,25 +51,6 @@ public:
bool isDisposed() const { return mbDisposed; }
- /** see general class documentation
- */
- static void * operator new(std::size_t nSize);
-
- /** see general class documentation
- */
- static void * operator new(std::size_t nSize,
- std::nothrow_t const & rNothrow)
- ;
-
- /** see general class documentation
- */
- static void operator delete(void * pPtr);
-
- /** see general class documentation
- */
- static void operator delete(void * pPtr, std::nothrow_t const & rNothrow)
- ;
-
protected:
virtual void disposing();
@@ -82,10 +63,6 @@ private:
void operator =(SimpleReferenceComponent) = delete;
- static void * operator new[](std::size_t) = delete;
-
- static void operator delete[](void * pPtr) = delete;
-
bool mbDisposed;
};
diff --git a/sd/source/helper/simplereferencecomponent.cxx b/sd/source/helper/simplereferencecomponent.cxx
index 872a6ce4052f..b53e382693cb 100644
--- a/sd/source/helper/simplereferencecomponent.cxx
+++ b/sd/source/helper/simplereferencecomponent.cxx
@@ -75,43 +75,4 @@ void SimpleReferenceComponent::disposing()
{
}
-void * SimpleReferenceComponent::operator new(std::size_t nSize)
-{
- return ::operator new(nSize);
-}
-
-void * SimpleReferenceComponent::operator new(std::size_t nSize,
- std::nothrow_t const &
-#ifndef _WIN32
- rNothrow
-#endif
- )
-{
-#if defined(_WIN32)
- return ::operator new(nSize);
- // WNT lacks a global nothrow operator new...
-#else // WNT
- return ::operator new(nSize, rNothrow);
-#endif // WNT
-}
-
-void SimpleReferenceComponent::operator delete(void * pPtr)
-{
- ::operator delete(pPtr);
-}
-
-void SimpleReferenceComponent::operator delete(void * pPtr,
- std::nothrow_t const &
-#ifndef _WIN32
- rNothrow
-#endif
-)
-{
-#if defined(_WIN32)
- ::operator delete(pPtr); // WNT lacks a global nothrow operator delete...
-#else // WNT
- ::operator delete(pPtr, rNothrow);
-#endif // WNT
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list