/* for strcpy */
-
- #include "mps.h"
- #include "mpsacl.h" /* for mps_arena_class_cl */
- #include "mpscmv.h" /* for mps_class_mv */
-
- static void reportPoolmv(mps_pool_t Pool)
- {
- size_t cbPoolFree = mps_mv_free_size(Pool);
- printf(
- "Pool has %lu bytes free.\n",
- (unsigned long)cbPoolFree
- );
- }
-
- int main(void)
- {
- void *pBlock = NULL;
- size_t cbBlock = 1024 * 1024;
- mps_arena_t ArenaDemo = NULL;
- mps_pool_t PoolDemo = NULL;
-
- mps_res_t res;
-
- {
- /* Create arena */
-
- pBlock = malloc(cbBlock);
- if(pBlock == NULL) {
- printf("malloc failed!\n");
- exit(1);
- }
-
- res = mps_arena_create(
- &ArenaDemo,
- mps_arena_class_cl(),
- cbBlock,
- pBlock
- );
- if (res != MPS_RES_OK) {
- printf("mps_arena_create: failed with res %d.\n", res);
- exit(2);
- }
- }
-
- {
- /* Create pool */
-
- size_t cbPoolExtend = 1024;
- size_t cbObjectAvg = 32;
- size_t cbPoolMax = 64 * 1024;
-
- size_t cbPoolFree = 0;
-
- res = mps_pool_create(
- &PoolDemo,
- ArenaDemo,
- mps_class_mv(),
- cbPoolExtend,
- cbObjectAvg,
- cbPoolMax
- );
- if (res != MPS_RES_OK) {
- printf("mps_pool_create: failed with res %d.\n", res);
- exit(2);
- }
-
- reportPoolmv(PoolDemo);
- }
-
- {
- /* Allocate memory */
-
- size_t cbBuffer = 100;
- void *p = NULL;
-
- res = mps_alloc(&p, PoolDemo, cbBuffer);
- if (res != MPS_RES_OK) {
- printf("mps_alloc: failed with res %d.\n", res);
- exit(2);
- }
-
- reportPoolmv(PoolDemo);
-
- {
- /* Show that it really is memory */
-
- char *pbBuffer = (char *)p;
-
- strcpy(pbBuffer, "hello--world\n");
- pbBuffer[5] = ',';
- pbBuffer[6] = ' ';
- printf(pbBuffer);
- }
- }
-
- printf(
- "Success: The hello-world example code successfully allocated\n"
- "some memory using mps_alloc(), in an MV pool, in a CL arena.\n"
- );
- return 0;
- }
-
-To compile and run this:
-
- % gcc 05alloc.c mps-kit-1.108.2/code/xcppgc/ci/mps.a mps-kit-1.108.2/code/xcppgc/ci/mpsplan.a
- % ./a.out
- % # (should say: "PoolDemo has 0 bytes free.")
- % # (and then: "PoolDemo has NNNN bytes free.", where NNNN depends on platform.)
- % # (and then: "hello, world")
-
-That's the end of this example code.
-
-
-DOCUMENT HISTORY
-
-2006-02-17 RHSK Created from scratch, referencing version/1.106.1
-2006-04-10 RHSK Tidy for release; refer to version/1.106.2
-2006-12-13 RHSK Version 1.107
-2007-07-06 RHSK Version 1.108
-2007-12-21 RHSK Release 1.108.1
-2008-05-01 RHSK Release 1.108.2
-
-
-COPYRIGHT AND LICENSE
-
-Copyright (C) 2006,2007 Ravenbrook Limited .
-All rights reserved. This is an open source license. Contact
-Ravenbrook for commercial licensing options.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-3. Redistributions in any form must be accompanied by information on how
-to obtain complete source code for this software and any
-accompanying software that uses this software. The source code must
-either be included in the distribution or be available for no more than
-the cost of distribution plus a nominal fee, and must be freely
-redistributable under reasonable conditions. For an executable file,
-complete source code means the source code for all modules it contains.
-It does not include source code for modules or files that typically
-accompany the major components of the operating system on which the
-executable file runs.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-[END]
diff --git a/mps/example/index.html b/mps/example/index.html
deleted file mode 100644
index e44a162b0d8..00000000000
--- a/mps/example/index.html
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
-
-
-
-Example Code
-
-
-
-
-
-
-
-
-
-
-This is the catalogue of example code for the Memory Pool System product.
-
- The example code shows you how to write code that uses the MPS. (In other words, how to use facilities in "mps.h").
-
-The simplest example — "hello-world" — gets you started using the MPS to allocate some memory to store and print the text "hello, world".
-
-This document is not confidential. The readership of this document is developers of client code that uses the MPS interface.
-
-Related documents:
-
-
-
-
-
-
-
-
- hello-world/ |
- simplest call to mps_alloc() — START HERE! |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- | 2006-04-10 |
- RHSK |
- Created (based on ../manual/index.txt). |
-
-
-
-
-
-
-
- This document is copyright © 2006 Ravenbrook Limited. All rights reserved. This is an open source license. Contact Ravenbrook for commercial licensing options.
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-
-
-- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
-- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-- Redistributions in any form must be accompanied by information on how to obtain complete source code for this software and any accompanying software that uses this software. The source code must either be included in the distribution or be available for no more than the cost of distribution plus a nominal fee, and must be freely redistributable under reasonable conditions. For an executable file, complete source code means the source code for all modules it contains. It does not include source code for modules or files that typically accompany the major components of the operating system on which the executable file runs.
-
-
-
- This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement, are disclaimed. In no event shall the copyright holders and contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
-
-
-
-
-
-
-
-
-