You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/07/28 23:59:58 UTC
cvs commit: xml-xalan/c/src/PlatformSupport ArenaBlock.hpp ReusableArenaAllocator.hpp ReusableArenaBlock.hpp
dbertoni 00/07/28 14:59:58
Modified: c/src/PlatformSupport ArenaBlock.hpp
ReusableArenaAllocator.hpp ReusableArenaBlock.hpp
Log:
Added functionality.
Revision Changes Path
1.5 +20 -8 xml-xalan/c/src/PlatformSupport/ArenaBlock.hpp
Index: ArenaBlock.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/ArenaBlock.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ArenaBlock.hpp 2000/07/10 22:45:28 1.4
+++ ArenaBlock.hpp 2000/07/28 21:59:56 1.5
@@ -111,14 +111,7 @@
~ArenaBlock()
{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::for_each;
-#endif
-
- // Destroy all existing objects...
- for_each(m_objectBlock,
- m_objectBlock + m_objectCount,
- DeleteFunctor(*this, m_destroyFunction));
+ destroyAll();
// Release the memory...
m_allocator.deallocate(m_objectBlock, 0);
@@ -263,6 +256,25 @@
{
return false;
}
+ }
+
+ /*
+ * Destroy all objects in the block. You can then reuse the
+ * block.
+ */
+ void
+ destroyAll()
+ {
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::for_each;
+#endif
+
+ // Destroy all existing objects...
+ for_each(m_objectBlock,
+ m_objectBlock + m_objectCount,
+ DeleteFunctor(*this, m_destroyFunction));
+
+ m_objectCount = 0;
}
protected:
1.8 +39 -2 xml-xalan/c/src/PlatformSupport/ReusableArenaAllocator.hpp
Index: ReusableArenaAllocator.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/ReusableArenaAllocator.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ReusableArenaAllocator.hpp 2000/07/12 19:26:26 1.7
+++ ReusableArenaAllocator.hpp 2000/07/28 21:59:56 1.8
@@ -119,8 +119,6 @@
bool
destroyObject(ObjectType* theObject)
{
- assert(m_blocks.size() != 0);
-
bool fSucess = false;
// Check this, just in case...
@@ -222,6 +220,45 @@
m_lastBlockReferenced->commitAllocation(theObject);
assert(m_lastBlockReferenced->ownsObject(theObject) == true);
+ }
+
+ virtual bool
+ ownsObject(const ObjectType* theObject) const
+ {
+ bool fResult = false;
+
+ // If no block has ever been referenced, then we haven't allocated
+ // any objects.
+ if (m_lastBlockReferenced != 0)
+ {
+ // Check the last referenced block first.
+ fResult = m_lastBlockReferenced->ownsObject(theObject);
+
+ if (fResult == false)
+ {
+ // Search back for a block with some space available...
+ ArenaBlockListType::const_reverse_iterator i = m_blocks.rbegin();
+ const ArenaBlockListType::const_reverse_iterator theEnd = m_blocks.rend();
+
+ while(i != theEnd)
+ {
+ assert(*i != 0);
+
+ if ((*i)->ownsObject(theObject) == true)
+ {
+ fResult = true;
+
+ break;
+ }
+ else
+ {
+ ++i;
+ }
+ }
+ }
+ }
+
+ return fResult;
}
private:
1.5 +1 -0 xml-xalan/c/src/PlatformSupport/ReusableArenaBlock.hpp
Index: ReusableArenaBlock.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/ReusableArenaBlock.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ReusableArenaBlock.hpp 2000/07/11 15:28:51 1.4
+++ ReusableArenaBlock.hpp 2000/07/28 21:59:56 1.5
@@ -98,6 +98,7 @@
~ReusableArenaBlock()
{
+ destroyAll();
}
/*