Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50477 - in sandbox/memory/libs/memory/examples: . simplest stl_containers
From: xushiweizh_at_[hidden]
Date: 2009-01-05 05:22:01


Author: xushiwei
Date: 2009-01-05 05:22:01 EST (Mon, 05 Jan 2009)
New Revision: 50477
URL: http://svn.boost.org/trac/boost/changeset/50477

Log:
boost-memory examples
Added:
   sandbox/memory/libs/memory/examples/ (props changed)
   sandbox/memory/libs/memory/examples/simplest/
   sandbox/memory/libs/memory/examples/simplest/simple_examples.cpp (contents, props changed)
   sandbox/memory/libs/memory/examples/simplest/vc9-win32.vcproj (contents, props changed)
   sandbox/memory/libs/memory/examples/stl_containers/
   sandbox/memory/libs/memory/examples/stl_containers/stl_containers.cpp (contents, props changed)
   sandbox/memory/libs/memory/examples/stl_containers/vc9-win32.vcproj (contents, props changed)

Added: sandbox/memory/libs/memory/examples/simplest/simple_examples.cpp
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/examples/simplest/simple_examples.cpp 2009-01-05 05:22:01 EST (Mon, 05 Jan 2009)
@@ -0,0 +1,73 @@
+//
+// simple_examples.cpp
+//
+// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/memory/index.htm for documentation.
+//
+#include <boost/memory.hpp>
+#include <boost/memory/linklib.hpp>
+
+// -------------------------------------------------------------------------
+
+void testAutoAlloc()
+{
+ NS_BOOST_MEMORY::auto_alloc alloc;
+
+ int* intObj = BOOST_MEMORY_NEW(alloc, int);
+ int* intObjWithArg = BOOST_MEMORY_NEW(alloc, int)(10);
+ int* intArray = BOOST_MEMORY_NEW_ARRAY(alloc, int, 100);
+ int* intBuf = BOOST_MEMORY_ALLOC(alloc, int);
+ int* intArrayBuf = BOOST_MEMORY_ALLOC_ARRAY(alloc, int, 100);
+
+ NS_BOOST_MEMORY::auto_alloc* subAlloc = BOOST_MEMORY_NEW(alloc, NS_BOOST_MEMORY::auto_alloc);
+
+ int* e = BOOST_MEMORY_NEW(*subAlloc, int);
+}
+
+void testScopedAlloc()
+{
+ NS_BOOST_MEMORY::block_pool recycle;
+ NS_BOOST_MEMORY::scoped_alloc alloc(recycle);
+
+ int* intObj = BOOST_MEMORY_NEW(alloc, int);
+ int* intObjWithArg = BOOST_MEMORY_NEW(alloc, int)(10);
+ int* intArray = BOOST_MEMORY_NEW_ARRAY(alloc, int, 100);
+ int* intBuf = BOOST_MEMORY_ALLOC(alloc, int);
+ int* intArrayBuf = BOOST_MEMORY_ALLOC_ARRAY(alloc, int, 100);
+
+ NS_BOOST_MEMORY::scoped_alloc* suballoc = BOOST_MEMORY_NEW(alloc, NS_BOOST_MEMORY::scoped_alloc)(alloc);
+
+ int* e = BOOST_MEMORY_NEW(*suballoc, int);
+}
+
+void testTlsScopedAlloc()
+{
+ NS_BOOST_MEMORY::scoped_alloc alloc;
+ // same as: NS_BOOST_MEMORY::scoped_alloc(boost::tls_block_pool::instance());
+
+ int* intObj = BOOST_MEMORY_NEW(alloc, int);
+ int* intObjWithArg = BOOST_MEMORY_NEW(alloc, int)(10);
+ int* intArray = BOOST_MEMORY_NEW_ARRAY(alloc, int, 100);
+ int* intBuf = BOOST_MEMORY_ALLOC(alloc, int);
+ int* intArrayBuf = BOOST_MEMORY_ALLOC_ARRAY(alloc, int, 100);
+
+ NS_BOOST_MEMORY::scoped_alloc* suballoc = BOOST_MEMORY_NEW(alloc, NS_BOOST_MEMORY::scoped_alloc);
+
+ int* e = BOOST_MEMORY_NEW(*suballoc, int);
+}
+
+int main()
+{
+ NS_BOOST_MEMORY::enableMemoryLeakCheck();
+
+ testAutoAlloc();
+ testScopedAlloc();
+ testTlsScopedAlloc();
+
+ return 0;
+}

Added: sandbox/memory/libs/memory/examples/simplest/vc9-win32.vcproj
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/examples/simplest/vc9-win32.vcproj 2009-01-05 05:22:01 EST (Mon, 05 Jan 2009)
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="simplest"
+ ProjectGUID="{EE4C99E9-EC3C-D26F-EE7F-A387A0E0425E}"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="Release/prj2json.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;NDEBUG;_MT"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=""
+ AssemblerListingLocation="Release/"
+ ObjectFile="Release/"
+ ProgramDataBaseFileName="Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;NDEBUG;_MT"
+ Culture="2052"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Release/simplest.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="../../lib"
+ GenerateDebugInformation="false"
+ ProgramDatabaseFile="Release/simplest.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="Debug/prj2json.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ InlineFunctionExpansion="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;_DEBUG;_MT"
+ StringPooling="true"
+ RuntimeLibrary="3"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=""
+ AssemblerListingLocation="Debug/"
+ ObjectFile="Debug/"
+ ProgramDataBaseFileName="Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;_DEBUG;_MT"
+ Culture="2052"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Debug/simplest.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="../../lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="Debug/simplest.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="simple_examples.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: sandbox/memory/libs/memory/examples/stl_containers/stl_containers.cpp
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/examples/stl_containers/stl_containers.cpp 2009-01-05 05:22:01 EST (Mon, 05 Jan 2009)
@@ -0,0 +1,72 @@
+//
+// stl_contianers.cpp
+//
+// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/memory/index.htm for documentation.
+//
+
+#include <set>
+#include <map>
+#include <list>
+#include <deque>
+#include <cstdio>
+
+#include <boost/memory.hpp>
+#include <boost/memory/linklib.hpp>
+
+using NS_BOOST_MEMORY::stl_allocator;
+
+// -------------------------------------------------------------------------
+
+enum { Count = 100 };
+
+void testDeque()
+{
+ printf("\n===== Deque (scoped_alloc) =====\n");
+ NS_BOOST_MEMORY::scoped_alloc alloc;
+ std::deque<int, stl_allocator<int> > s(alloc);
+ for (int i = 0; i < Count; ++i)
+ s.push_back(i);
+}
+
+void testList()
+{
+ printf("\n===== List (scoped_alloc) =====\n");
+ NS_BOOST_MEMORY::scoped_alloc alloc;
+ std::list<int, stl_allocator<int> > s(alloc);
+ for (int i = 0; i < Count; ++i)
+ s.push_back(i);
+}
+
+void testSet()
+{
+ printf("\n===== Set (scoped_alloc) =====\n");
+ NS_BOOST_MEMORY::scoped_alloc alloc;
+ std::set<int, std::less<int>, stl_allocator<int> > s(std::less<int>(), alloc);
+ for (int i = 0; i < Count; ++i)
+ s.insert(i);
+}
+
+void testMap()
+{
+ printf("\n===== Map (scoped_alloc) =====\n");
+ NS_BOOST_MEMORY::scoped_alloc alloc;
+ std::map<int, int, std::less<int>, stl_allocator<int> > s(std::less<int>(), alloc);
+ for (int i = 0; i < Count; ++i)
+ s.insert(std::pair<int, int>(i, i));
+}
+
+int main()
+{
+ testDeque();
+ testList();
+ testSet();
+ testMap();
+
+ return 0;
+}

Added: sandbox/memory/libs/memory/examples/stl_containers/vc9-win32.vcproj
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/examples/stl_containers/vc9-win32.vcproj 2009-01-05 05:22:01 EST (Mon, 05 Jan 2009)
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="simplest"
+ ProjectGUID="{EE4C99E9-EC3C-D26F-EE7F-A387A0E0425E}"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="Release/prj2json.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;NDEBUG;_MT"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=""
+ AssemblerListingLocation="Release/"
+ ObjectFile="Release/"
+ ProgramDataBaseFileName="Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;NDEBUG;_MT"
+ Culture="2052"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Release/simplest.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="../../lib"
+ GenerateDebugInformation="false"
+ ProgramDatabaseFile="Release/simplest.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName="Debug/prj2json.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ InlineFunctionExpansion="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;_DEBUG;_MT"
+ StringPooling="true"
+ RuntimeLibrary="3"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=""
+ AssemblerListingLocation="Debug/"
+ ObjectFile="Debug/"
+ ProgramDataBaseFileName="Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="WIN32;__32BIT__;_CONSOLE;_DEBUG;_MT"
+ Culture="2052"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Debug/simplest.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="../../lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="Debug/simplest.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\stl_containers.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk